我的数据是从另一个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条经验 获得超10个赞
Debug 看下这一行执行后,cursor 的值
Cursor cursor = sqLiteDatabase.query(CustomOpenHelper.TABLE_NAME,null,null,null,null,null,null);
- 1 回答
- 0 关注
- 218 浏览
添加回答
举报
0/150
提交
取消