lundi 13 juillet 2015

how to solve the cursorwindow failed to read illegalstateexception in android?

I have written a program to insert some values inside sqlite database which is working perfectly , i want to get values of two columns but unable to get as it is throwing IllegalStateException.

07-13 17:44:28.776: E/CursorWindow(18158): Failed to read row 0, column -1 from a CursorWindow which has 2 rows, 11 columns.

public Cursor getIMEIno(String imei){
    SQLiteDatabase db = helper.getWritableDatabase();
    Cursor cursor = db.rawQuery("Select "+DbListHelper.UID+","+
    DbListHelper.CLIENT_CODE+","+DbListHelper.TRANSACTION_ID+" from  
    "+DbListHelper.TABLE_NAME_FINALDATA+" where "+
    DbListHelper.TRANSACTION_ID+" = '" + imei + "' limit 1",null);
    return cursor;
}


imgPostSync.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Sync under process",
                    Toast.LENGTH_LONG).show();
            try {
                TelephonyManager telephonyManager = (TelephonyManager) 
                getSystemService(Context.TELEPHONY_SERVICE);
                IMEI_No = telephonyManager.getDeviceId();
                if (IMEI_No == null) {
                } else {
                    c = listHelper.getIMEIno(IMEI_No);
                    if (c.getCount() == 0) {
                        Toast.makeText(getApplicationContext(),
                                "Problem IMEI", Toast.LENGTH_LONG).show();
                    } else {
                        c = listHelper.getIMEIno(IMEI_No);
                        if (c.moveToFirst()) {
                            //do {
                                String clcode = c.getString(c
                            .getColumnIndex(DbListHelper.CLIENT_CODE));
                                String imei = c.getString(c
                           .getColumnIndex(DbListHelper.TRANSACTION_ID));

                                postData(imei, clcode); 

                            //} while (c.moveToNext());

                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });

Please need some help in solving the error

Thanking You

Aucun commentaire:

Enregistrer un commentaire