我使用這個代碼,但它返回空值。當我調試我的代碼,顯示其給出的空值列表返回空值
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
我的日誌
E/Spinner value is: --=> speech
E/inside: getDetailtospinner
E/Cursor is: ==>[email protected]
E/0_0: 0_0 1=>
E/Hey: last
幫我出這一點。
爲什麼你需要檢查'cursor.isLast()'? –
在'while'中放置一個'Log',看看'cursor'是否返回數據。 – Venky
看我的日誌venky – newdeveloper