-1

I am trying to fetch some data in my android code from sqlite table.I am getting an unrecognized token exception. Kindly help. This is the relevant portion of my code:

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;
            }

This is the relevant portion of logcat

E/AndroidRuntime(6447): Caused by: android.database.sqlite.SQLiteException: unrecognized token: "[I@406488d0)": , while compiling: SELECT * FROM applist WHERE _id IN [I@406488d0)

ambit
  • 1,099
  • 2
  • 28
  • 43
  • 2
    It's seems that `cntin` variable is equal `[I@405c6240` string. Do you sure your Raw query text is correct? You could try to remove `+ cntin` part from your query. – Evos Dec 29 '12 at 06:07
  • 1
    ambit: Why do yo have the `cntin` variable appended to the end of your query? – PCoder Dec 29 '12 at 06:09
  • 1
    whats the purpose of cntin while u r using hardcoded "cntappid=36" – Soumyadip Das Dec 29 '12 at 06:15
  • Apologies for posting the wrong code. I tried to remove the unnecessary stuff from my code and ended up pasting some portion of my commented code. I have edited the question now. Please review it and kindly let me know if you can help. Thanks. – ambit Dec 29 '12 at 09:51
  • What's the reason for downvote? :( – ambit Dec 31 '12 at 06:59

1 Answers1

0

Remove cntin and try again I think the query is not valid with the variable appended at the end of the query string.

Sathirar
  • 331
  • 4
  • 17