Android Question Cannot get DBUtils to work - get error

tseyfarth

Member
Licensed User
Longtime User
Hello all,

I get an error when launching the app:
Error occurred on line: 215 (DBUtils)

android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/1.db' with flags 0x10000010: File /storage/emulated/0/1.db doesn't exist and CREATE_IF_NECESSARY is set, check directory permissions

Is this a permissions issue? If so, what permission is missing and how to programatically change those permissions?

I am using DBUtils library 2.11

Thank you,

Tim
 

mcqueccu

Well-Known Member
Licensed User
Longtime User
My best guess is you are loading the db from DirRootExternal which is not possible in latest android.
Put your database in dirInternal that is (xui.DefaultFolder)
 
Upvote 0

tseyfarth

Member
Licensed User
Longtime User
Hello mcqueccu,

This is a sample from Erel. I cannot find any .db files included with the sample. However, you are correct about the folders - I think...

I changed the code from this:
B4X:
File.Delete(File.DirRootExternal, "1.db")
    sql.Initialize(File.DirRootExternal, "1.db", True)


To this:
B4X:
File.Delete(File.dirInternal, "1.db")
    sql.Initialize(File.dirInternal, "1.db", True)



And now it does work -
Thank you!
Tim
 
Upvote 0
Top