查询代码:
公共Cursor SelectRecord(){
SQLiteDatabase db = this.getReadableDatabase();
String Query="SELECT * FROM TABLE_NAME";
Cursor c = db.query(TABLE_NAME, new String[]{"user_id _id","f_name","l_name","password"}, null, null, null, null, null);
if (c != null)
c.moveToFirst();
return c;
}
我也尝试将rowid列,但是它不起作用。
简单光标适配器代码:
最终DatabaseHelper db = new DatabaseHelper(getApplicationContext());
Cursor c=db.SelectRecord();
String[] from={"_id","f_name","l_name","password"};
int[] to={R.id.textView1,R.id.textView2,R.id.textView3,R.id.textView4};
SimpleCursorAdapter adapter=new SimpleCursorAdapter(Edit.this,R.layout.list_data,c,from,to);
ListView lv=(ListView)findViewById(R.id.listview1);
lv.setAdapter(adapter);
数据库代码:
公共静态最终字符串TABLE_NAME =“ Master”;
public static final String ColumnID = "user_id";
public static final String Column_2 = "f_name";
public static final String Column_3 = "l_name";
public static final String Column_4 = "password";
public static final String Column_5 = "confirm_pass";
//我的错误就像这样:
column '_id' does not exist.Available columns:[user_id,f_name,l_name,password]