-1

我正在尝试从 sqlite 表中获取我的 android 代码中的一些数据。我得到一个无法识别的令牌异常。请帮忙。这是我的代码的相关部分:

private static final String APPS_CREATE =
        "create table applist (" +
                    "_id integer primary key, " +
                    "deviceid int(10) not null," +
                    "catid int(10)," +
                         ............



private static final String APPCNT_CREATE =
            "create table appcntlist (" +
                    "_id integer primary key, "+
                    "appcntid int , " +
                    "cntappid int);";
    .........................

      public Cursor fetchCntNotes(String cnt){

        Cursor appfinlist=null;

        Cursor temp=mDb.query(CNT_TABLE, new String[]{KEY_ROWID}, KEY_CNTNM + "=\"" + cnt + "\"", null, null , null, null);
        Cursor applist;

        if(temp.moveToFirst()){
            id=temp.getInt(temp.getColumnIndexOrThrow(DbAdapter.KEY_ROWID));
            Log.d("amit","countryname id: "+ id);

            applist=mDb.rawQuery("SELECT appcntid FROM appcntlist WHERE cntappid = "+id, null);
            if(applist.moveToFirst()){
                int[] cntin=new int[applist.getCount()];
                for(int i=0;i<applist.getCount();i++){
                    Log.d("amit","countryname id appid: " + applist.getInt(applist.getColumnIndexOrThrow(DbAdapter.KEY_APPCNTID)));
                    cntin[i]=applist.getInt(applist.getColumnIndexOrThrow(DbAdapter.KEY_APPCNTID));
                    Log.d("amit","countryname id cnt var: " + cntin[i]);
                    applist.moveToNext();   
                }
                appfinlist = mDb.rawQuery("SELECT * FROM applist WHERE _id IN "+cntin+")", null);
                return appfinlist;
            }

这是 logcat 的相关部分

E/AndroidRuntime(6447): 由: android.database.sqlite.SQLiteException: unrecognized token: "[I@406488d0)": , 编译时: SELECT * FROM applist WHERE _id IN [I@406488d0)

4

1 回答 1

0

删除并重cntin试我认为查询无效,查询字符串末尾附加了变量。

于 2012-12-29T07:18:21.857 回答