我正在尝试在android中显示特定行的值,以检查是否存在特定更新。我能否成功?但是由于返回类型为cursor
,所以我不知道如何获取它。所以请帮助我。
public Cursor getData(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("select * from calls where id=" + id + "", null);
return res;
}
最佳答案
获取行值作为字符串。然后返回字符串值。
public String getData(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("select * from calls where id=" + id + "", null);
if (res.getCount() > 0) {
res.moveToFirst();
String s = res.getString(res.getColumnIndex("id"));
return s;
}
关于android - 显示特定行的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47594437/