5

我在一台设备上收到此错误,而它在另一台设备上运行良好。这是错误:

Caused by: android.database.sqlite.SQLiteException: not an error
    at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method)
    at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86)
    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164)
    at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
    at com.Orange.MakeVisits.Themes.onCreate(Themes.java:162) 

我执行一个查询,并在检查 Cursor 是否为空的那一行,我得到了这个错误。这是我的代码:

    String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a "
   + "inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id "
   + "where b.starring_id = '"+pos_starring_id+"' and a.theme_id='"+themes_ids[m]+"' order by form_rank";

    Cursor getThemesCursor1 = db.databaseQuery(stmtGetThemes);

    if (getThemesCursor1!=null && getThemesCursor1.getCount()>0){
    //----
    }

和 databasequery 是这个方法(在扩展类中定义SQLiteOpenHelper):

public Cursor databaseQuery(String stmt) {
        Cursor cursor = db.rawQuery(stmt, null);
        return cursor;
    }

知道什么会导致此错误吗?说法不好吗?为什么它适用于其他设备?欢迎任何想法。预先感谢。

4

2 回答 2

0

不要在查询中传递数组类型参数,有时它不起作用

int themes_id = themes_ids[m];

String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id where b.starring_id = '"+pos_starring_id+"' AND a.theme_id = '"+themes_id+"' ORDER BY form_rank";

Cursor getThemesCursor1 = db.databaseQuery(stmtGetThemes);

if (getThemesCursor1 != null && getThemesCursor1.getCount() != 0){
//----
}
于 2012-10-27T10:29:49.143 回答
0
String stmtGetThemes = "SELECT * FROM pr_fields_descriptor a "
   + "inner join pr_fields_starring b on a.id_fields_descriptor = b.fields_descriptor_id "
   + "where b.starring_id = '"+pos_starring_id+"' and a.theme_id='"+themes_ids[m]+"' order by form_rank";

不要用“;”终止这个查询。

于 2012-10-27T10:30:09.400 回答