CursorWindow列数 [英] CursorWindow number of columns

查看:190
本文介绍了CursorWindow列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能知道多少列有一个 CursorWindow
为什么它有一个 getNumRows(),但没有 getNumColumns(),尽管有一个 setNumColumns( )

How can I know how many columns there are on a CursorWindow? Why it has a getNumRows() but no getNumColumns(), despite having a setNumColumns()?

推荐答案

我做了这个最可怕的方式:

/**
 * Get the number of columns of this CursorWindow. The CursorWindow has to
 * have at least one row.
 */
public static int getCursorWindowNumCols(CursorWindow window) {

    // Ugly hack...
    int j = 0;
    while (true) {
        try {
            window.getString(0, j);
        } catch (IllegalStateException e) {
            break;
        } catch (SQLException e) {
            // It's a BLOB!
        }
        j++;
    }
    return j;
}

我不建议用这个。刚刚发布,如果有人有相同的问题,需要一个快速的解决方案,使移动。

I don't recommend using this. Just posting it if someone has the same problem and needs a quick solution to get moving.

这篇关于CursorWindow列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆