Earlier I asked this question ( and after some googling I read Using your own SQLite database for Android app.
So, I have a simple database which contains 2 columns (_id and quotes). What I need to do is to grab all the quotes from the db and show them 1 by 1 in a TextView.
I have this in my DataBaseHelper.java:
private SQLiteDatabase myDataBase;
public void openDataBase() throws SQLException{
//Open the database
String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
Cursor mCursor = myDataBase.query(true, DB_NAME, null, new String[] + "=" + "_id", null,
null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
What should I do? Thanks
This function is how I fetch data from a database where “db” is the database instance.
This function will return an 2D String array where [0][x] is the first row it fetched and [1][x] is the second, etc; and the x is the columns, and in your case [0][1] would be the first quote in your database.