mercredi 12 août 2015

Opening existing database created with SQLiteStudio

Currently the error message I get is that the file cannot be opened. All I'm trying to do is open my database, open my table and extract the information from this. Below is what I have so far:

public class MainActivity extends Activity
{
private static final String DATABASE_NAME = "ExerciseDatabase.db";
private static final String DATABASE_TABLE = "ExerciseList";

SQLiteDatabase myDatabase;

private void openDatabase(){
    myDatabase = openOrCreateDatabase("/databaseManipulation/assets/" + DATABASE_NAME, Context.MODE_PRIVATE, null);

}

protected void onCreate(Bundle savedInstanceState) {      
openDatabase();
Cursor allData = myDatabase.rawQuery("SELECT * FROM ExerciseList", null);
Log.e("TESTLOG", allData.toString());

}
}

From what I've read it seems to suggest creating a new database and overwriting it with my existing one, any help would be great

Aucun commentaire:

Enregistrer un commentaire