After update to Android 6.0, SQLite database crashes

Viewed 3898

I use this code to work with SQLite.

Before I update to android 6.0, it works perfectly, but now it crashes.

in MyParam class

public static SQLiteDatabase dbMyCount;
public static String DB_Path_MyCount = "/sdcard/GMS/MyCount.db";

on MainActivity

MyParam.dbMyCount = this.openOrCreateDatabase(MyParam.DB_Path_MyCount, MODE_WORLD_WRITEABLE, null);
SQL  = "CREATE TABLE IF NOT EXISTS MyCount(_id INTEGER PRIMARY KEY AUTOINCREMENT,Tdate VARCHAR,Cust VARCHAR,";
SQL += "Prog VARCHAR,CustCode VARCHAR,OpenCode VARCHAR,Memo VARCHAR)";
MyParam.dbMyCount.execSQL(SQL);

I also updated my manifast to this:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

But still got error:

Error Code : 1294 (SQLITE_CANTOPEN_ENOENT) Caused By : Specified directory or database file does not exist. (unknown error (code 1294): Could not open database)

I searched the Web and could not find any answer or solution.

Thanks.

1 Answers
Related