我的數(shù)據(jù)是從另一個activity intent過來的。Intent intent = getIntent();String inputName = intent.getStringExtra("content");String inputScore = intent.getStringExtra("timeSpent");SQLiteDatabase db = myOpenHelper.getWritableDatabase();ContentValues values = new ContentValues();//Retrieve the intentvalues.put("name", inputName);int intScore = Integer.parseInt(inputScore);values.put("score", intScore);db.insert(CustomOpenHelper.TABLE_NAME, null, values);displayDataInTable();——————————————————————————————List<String> queryTable(){List<String> player = new ArrayList<String>();SQLiteDatabase sqLiteDatabase = myOpenHelper.getReadableDatabase();Cursor cursor = sqLiteDatabase.query(CustomOpenHelper.TABLE_NAME,null,null,null,null,null,null);while (cursor.moveToNext()){String name = cursor.getString(cursor.getColumnIndex("name"));int score = cursor.getInt(cursor.getColumnIndex("score"));player.add(" --> the player " + name + " has got a score of " +score);}return player;}
1 回答

holdtom
TA貢獻1805條經(jīng)驗 獲得超10個贊
Debug 看下這一行執(zhí)行后,cursor 的值
Cursor cursor = sqLiteDatabase.query(CustomOpenHelper.TABLE_NAME,null,null,null,null,null,null);
- 1 回答
- 0 關(guān)注
- 236 瀏覽
添加回答
舉報
0/150
提交
取消