I have a database that I have created with the following handler:
public class DatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "trade.db";
public static final String RESOURCEID = "resourceid";
public static final String STARTPRICE = "startprice";
public static final String CURRENTBID = "currentbid";
public static final String EXPIRES = "expires";
public static final String BUYNOWPRICE = "buynowprice";
public static final String TYPE = "type";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL( "CREATE TABLE cards (_id INTEGER PRIMARY KEY AUTOINCREMENT, resourceid TEXT, startprice TEXT,currentbid TEXT, expires TEXT, buynowprice TEXT, type TEXT);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
android.util.Log.w("cards",
"Upgrading database, which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS ");
onCreate(db);
}
}
I would like to display the items of this DB in a listview where items are selectable, unfortunately I am a complete android nooby (first application). Could someone please explain to me how I would do this? I am well aware there are some examples out there, but I am simply unable to follow them. Thanks
No tutorial, just some things you’ll need:
getReadableDatabase()-method ofyour
SQLiteOpenHelper