我想获得一个带有id的行的单列,我应该
String selQ = "SELECT " + name + " FROM " + table+ " WHERE " + id+ " = '" + id + "'";
或
String selQ = "SELECT * FROM " + table + " WHERE " + id+ " = '" + id + "'";
我得到一个光标吗?
答案 0 :(得分:1)
你可以使用query()方法
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="LaLaLa">
</TextView>
或者你可以执行行查询,就像你提出的一些错误被删除
private Cursor getSingleRow(int id){
Cursor cur = db.query(TABLE, null,
"_id= ?", new String[] { "" + id }, null,
null, null);
if (cur != null) {
cur.moveToFirst();
}
return cur;
}
答案 1 :(得分:0)
*表示表中的所有列,如果您只需要指定的名称。 一旦你创建了字符串,就可以使用rawQuery()函数。