A anaylor01 Well-Known Member Licensed User Longtime User Aug 13, 2015 #1 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.
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.
A anaylor01 Well-Known Member Licensed User Longtime User Aug 13, 2015 #2 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
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)
klaus Expert Licensed User Longtime User Aug 13, 2015 #4 Unfortunately you don't give enough information to give a concrete advice. Can't you post a small project showing the problem as a zip file ? So we could test it and see where the problem is. Upvote 0
Unfortunately you don't give enough information to give a concrete advice. Can't you post a small project showing the problem as a zip file ? So we could test it and see where the problem is.
A anaylor01 Well-Known Member Licensed User Longtime User Aug 13, 2015 #5 This is the line that it errors on. SQL1.Initialize(File.DirDefaultExternal, "test1.db", True) Upvote 0
M Mahares Expert Licensed User Longtime User Aug 13, 2015 #6 anaylor01 said: SQL1.Initialize(File.DirDefaultExternal, "test1.db", True) Click to expand... That line 's syntax is correct. The problem is elsewhere. You need to listen to what @klaus is asking you to do. Upvote 0
anaylor01 said: SQL1.Initialize(File.DirDefaultExternal, "test1.db", True) Click to expand... That line 's syntax is correct. The problem is elsewhere. You need to listen to what @klaus is asking you to do.
A anaylor01 Well-Known Member Licensed User Longtime User Aug 13, 2015 #7 Attached is the file. Attachments DatabaseTest.zip DatabaseTest.zip 7 KB · Views: 309 Upvote 0
M Mahares Expert Licensed User Longtime User Aug 13, 2015 #8 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 Code: Copy If FirstTime Then SQL1.Initialize(File.DirInternal, "test1.db", True) End If Upvote 0
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 Code: Copy If FirstTime Then SQL1.Initialize(File.DirInternal, "test1.db", True) End If
A anaylor01 Well-Known Member Licensed User Longtime User Aug 13, 2015 #9 The problem was I didn't have an SD setup for my emulator. Thanks guys. Upvote 0
A anaylor01 Well-Known Member Licensed User Longtime User Aug 14, 2015 #10 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
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
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2015 #11 anaylor01 said: Are there any changes I need to make to the Manifest for internal like I had to do for external? Click to expand... No. You also don't need to do any change for the external folder. Can you post the relevant code and the full error message? Upvote 0
anaylor01 said: Are there any changes I need to make to the Manifest for internal like I had to do for external? Click to expand... No. You also don't need to do any change for the external folder. Can you post the relevant code and the full error message?
A anaylor01 Well-Known Member Licensed User Longtime User Aug 14, 2015 #12 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
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
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2015 #13 Please post the full error message from the logs. You should right click on the logs and paste it in the post. Upvote 0
Please post the full error message from the logs. You should right click on the logs and paste it in the post.
A anaylor01 Well-Known Member Licensed User Longtime User Aug 14, 2015 #14 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
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)
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2015 #15 Seems like a problem in the emulator. I recommend you to use a real device instead. Upvote 0