newdeveloper newdeveloper - 4 months ago 21
Android Question

list return null value

i am using this code but this code return null value when i am debug my code that show its given null value

List<TextJson> textList = null;
try{
textList = new ArrayList<TextJson>();
Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = '" + text_spinner1 + " ' " , null);
Log.e("Cursor is","==>"+cursor);
Log.e("0_0", "0_0 1=>"); // code working on here
if(!cursor.isLast())
{
Log.e("Hey","last");
while (cursor.moveToNext())
{
TextJson txtlist = new TextJson();
txtlist.setId(cursor.getInt(0));
txtlist.setText_status(cursor.getString(1));
textList.add(txtlist);
}
}
db.close();
}catch (Exception e){
Log.e("error","is==> " +e);
}
return textList; // null value


my log

E/Spinner value is: --=> speech
E/inside: getDetailtospinner
E/Cursor is: ==>android.database.sqlite.SQLiteCursor@41b0f5d8
E/0_0: 0_0 1=>
E/Hey: last


help me out of this....

Answer

Change

Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = '" + text_spinner1 + " ' " , null);

to

Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = '" + text_spinner1 + "'" , null);
// or Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " LIKE '" + text_spinner1 + "'" , null);
Comments