使用 Cursor 从数据库中获取数据
Database db = new Database(this);
Cursor yourdata = db.getDetails(this);
if(yourdata!=null)
{
yourdata.moveToFirst();
String value= cursor.getString(cursor.getColumnIndex(databaseColumn);
TextView youtextview = (TextView) findViewById(R.id.textview);
youtextview .setText(value);
}
在数据库类中创建 getDetails() 方法。
public Cursor getDetails(Activity youactivity,
int projectid) {
SQLiteDatabase db = getReadableDatabase();
String from[] = { YourColumn};
String where = ID+"="+projectid;
Cursor cursor = db.query(true, Table, from, where, null, null, null, null, null);
return cursor;
}
希望能帮助到你