sqlite数据库的查询,急
我尝试了一些方法,始终还是不能正确的解决sqlite的查询,头大,急求高人指点
假如我有一个数据库,里面装了5条信息,只有id和信息,我自己写来写去对这些参数就搞混了,求更改。
想法很简单,我在其它地方调用的时候,将id作为参数传进去,就能得到信息。
不胜感激啊。。。
public String query(int i){
String msgQuery = null;
SQLiteDatabase db = this.getReadableDatabase();
String[] col = {"id", "msg"};
Cursor cursor = db.query(TABLE_NAME, col, null, null, null, null, null);
while(cursor.moveToNext()) {
msgQuery = (cursor.getColumnName(i));
}
db.close();
return msgQuery;
}