到目前为止我得到了这个
db = new MYDBHelper(this);
constantsCursor = db.getReadableDatabase().rawQuery(
"SELECT _ID, title, value " + "FROM constants ORDER BY title", null);
ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, constantsCursor, new String[] { DBHelperMen2.TITLE, DBHelperMen2.VALUE }, new int[] {R.id.item_name, R.id.item_points });
listata = (ListView) findViewById(R.id.listView1);
listata.setAdapter(adapter);
但我还有一个名为 item_number 的字段。我这个字段我要写_ID号
我怎样才能做到这一点 ?
new SimpleCursorAdapter(this, R.layout.item, constantsCursor, new String[] { **???** ,MYDBHelper.TITLE, MYDBHelper.VALUE }, new int[] {**R.id.item_number** , R.id.item_name, R.id.item_points });
这是 MYDBHelper
public class MYDBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "db";
static final String TITLE = "title";
static final String VALUE = "value";
public MYDBHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE constants (_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, value TEXT);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS constants");
onCreate(db);
}
}