sqlite表中有几列。我想使用行ID检索特定数据。例如:我想要列“name”的数据,其行号为“1”。我怎么能在android中做到这一点?
答案 0 :(得分:0)
我的代码示例:
private static String t(String i, String table) {
SQLiteDatabase db = ODB.getInstance().openDatabase();
String lng = hl;
String Sid = "Sid___";
String sql = "SELECT " + lng + " FROM " + table + " WHERE " + Sid + " = '" + i + "'";
Cursor cur = db.rawQuery(sql, null);
String out = "";
if (cur.moveToFirst()) {
do {
out =(cur.getString(0);
} while (cur.moveToNext());
}else{
throw new NullPointerException();
}
cur.close();
ODB.getInstance().closeDatabase();
return out;
}