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.
Please follow suggestion given by CommonsWare. But also for marshmallow i.e android 6.0 and above you need to ask for run time permissions. Please have a look at the link below
http://developer.android.com/training/permissions/requesting.html
Only specifying in the manifest in not enough as per android's new runtime permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With