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)
);
Edit: Okay, I have new information. If I so much as take the db file, email it to myself, and replace it back into the original directory. It'll crash. Yes you heard me. I don't even alter the file, I just email the file to myself, delete the original, and replace it with the exact same file. Then it crashes. I'm about to tear my hair out.
As I can see, you are opening the DB in read-only mode. Adding the table - is a modification, and exception thrown shows you that you should open it in write mode before modifying it scheme or adding\deleting some data.