Android Question SQL ERROR WRITE_EXTERNAL_STORAGE

anaylor01

Well-Known Member
Licensed User
Longtime User
I am starting to use my first database and am getting an error.
sql1.initialize(file.dirdefaultexternal,"android.database.sqlite.SQLite Can't Open Database Exception: Unable to open database file.

From what I found I need to add Write External something to the Manifest file.
 

anaylor01

Well-Known Member
Licensed User
Longtime User
I added the below to the Manifest but I get the same error.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I tested your project and it creates the file test1.db to File.DefaultExternal on my device with no problems. Maybe your device does not have an external sd.
Try this: File.DirInternal instead of File.DirDefaultExternal
B4X:
If FirstTime Then
        SQL1.Initialize(File.DirInternal, "test1.db", True)
    End If
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Ok. Now I changed it to internal and am getting the below error. Here is what I changed the code to. Are there any changes I need to make to the Manifest for internal like I had to do for external?
SQL1.Initialize(File.DirInternal, "ThinkFast.db", True)

sql1.initialize(file.dirinternal,"thinkfast"
java.lang.nullpointerexception
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
It is the same as the file I posted except I changed the line from dirdefaultexternal to dirinternal and the error is
sql1.initialize(file.dirinternal,"thinkfast"
java.lang.nullpointerexception
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
setKernelCountSet(10022, 0) failed with errno -2
createSurface Window{4130cc20 b4a.example/b4a.example.main paused=false}: DRAW NOW PENDING
Displayed b4a.example/.main: +3s555ms
** Activity (main) Create, isFirst = true **
Unable to create files directory /data/data/b4a.example/files
main_activity_create (B4A line: 54)
SQL1.Initialize(File.Dirinternal, "test1.d
java.lang.NullPointerException
at anywheresoftware.b4a.objects.streams.File.getDirInternal(File.java:51)
 
Upvote 0
Top