jeudi 30 avril 2015

Altering db file is causing SQLiteDatabase.openDatabase() to crash

I have a normal opening of a database file, it works perfectly fine when opening a blank db file with only the metadata table, but as soon as I make another table, it causes the app to crash. Maybe it's different version db files? Please comment if you need more of the code

private static String DB_PATH = "/data/data/com.example.andrew.ubair4/databases/";    
private static String DB_NAME = "coordinates";
String myPath = DB_PATH + DB_NAME;

private SQLiteDatabase db;
public DataBaseHelper(Context context){

    super(context, DB_NAME, null, 1);
    this.myContext = context;
    Log.d("TAGG","enter constructor");

    db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);      //<---- crashes right here IF I have a second table in the database
    Log.d("TAGG","2");

My metadata table:

CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')
INSERT INTO "android_metadata" VALUES ('en_US')

Add 1 more table:

CREATE TABLE something (
  column1, 
  column2, 
  column3, 
  PRIMARY KEY (column1)
);

Aucun commentaire:

Enregistrer un commentaire