J JimReid New Member Licensed User Longtime User May 7, 2012 #1 I just got Basic4android and love it so far but trying my first sql program. The following statement: SQL1.Initialize("c:\androidtest", "BooksIveRead", True) Won't initialize my database. Gives following error: Error occured An error has occured in sub: main_activity-create(B4aLine:25) SQL1.Initialize("c\androidtest","BooksIveRead",True) android.database.sqlite SQLiteCantOpenDatabaseException:unable to open database file Continue? I read that if the parameter 'True' is specified it would create the database. Is this not accurate? 'False' or blank should only open it. Any help would be appreciated. Jim Reid:sign0085:
I just got Basic4android and love it so far but trying my first sql program. The following statement: SQL1.Initialize("c:\androidtest", "BooksIveRead", True) Won't initialize my database. Gives following error: Error occured An error has occured in sub: main_activity-create(B4aLine:25) SQL1.Initialize("c\androidtest","BooksIveRead",True) android.database.sqlite SQLiteCantOpenDatabaseException:unable to open database file Continue? I read that if the parameter 'True' is specified it would create the database. Is this not accurate? 'False' or blank should only open it. Any help would be appreciated. Jim Reid:sign0085:
corwin42 Expert Licensed User Longtime User May 7, 2012 #2 Hey, this is not Windows, it's Android. Code: Copy SQL1.Initialize(File.DirInternal, "BooksIveRead.db", True) (Your path is wrong) Upvote 0
Hey, this is not Windows, it's Android. Code: Copy SQL1.Initialize(File.DirInternal, "BooksIveRead.db", True) (Your path is wrong)
M Mahares Expert Licensed User Longtime User May 7, 2012 #3 SQL1.Initialize("c:\androidtest", "BooksIveRead", True) needs to be something like: Code: Copy SQL1.Initialize(File.DirRootExternal & "/androidtest", "BooksIveRead", True) or Code: Copy SQL1.Initialize(File.DirInternal & "/androidtest", "BooksIveRead", True) or Code: Copy SQL1.Initialize(File.DirDefaultExternal & "/androidtest", "BooksIveRead", True) Last edited: May 7, 2012 Upvote 0
SQL1.Initialize("c:\androidtest", "BooksIveRead", True) needs to be something like: Code: Copy SQL1.Initialize(File.DirRootExternal & "/androidtest", "BooksIveRead", True) or Code: Copy SQL1.Initialize(File.DirInternal & "/androidtest", "BooksIveRead", True) or Code: Copy SQL1.Initialize(File.DirDefaultExternal & "/androidtest", "BooksIveRead", True)
S snutting New Member Licensed User Longtime User Mar 29, 2013 #4 Same SQLiteCantOpenDatabaseException Issue Sorry everyone but I am having the same issue and do not see that there are any other forum threads for this error. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database. I am using an SQL example straight from the forum. Do I need to create the test.db somewhere prior to running this code? Is it because I am using an emulator? Here is the code: Sub Activity_Create(FirstTime As Boolean) If FirstTime Then SQL1.Initialize(File.DirDefaultExternal, "test.db", True)End IfEnd Sub Thanks! ** UPDATE ** I think I found the fix. I changed the path to File.DirInternal instead of File.DirDefaultExternal and it worked just fine. There was some kind of permissions issue writing to File.DirDefaultExternal is that normal for an emulator? Last edited: Mar 29, 2013 Upvote 0
Same SQLiteCantOpenDatabaseException Issue Sorry everyone but I am having the same issue and do not see that there are any other forum threads for this error. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database. I am using an SQL example straight from the forum. Do I need to create the test.db somewhere prior to running this code? Is it because I am using an emulator? Here is the code: Sub Activity_Create(FirstTime As Boolean) If FirstTime Then SQL1.Initialize(File.DirDefaultExternal, "test.db", True)End IfEnd Sub Thanks! ** UPDATE ** I think I found the fix. I changed the path to File.DirInternal instead of File.DirDefaultExternal and it worked just fine. There was some kind of permissions issue writing to File.DirDefaultExternal is that normal for an emulator?
Erel B4X founder Staff member Licensed User Longtime User Mar 30, 2013 #5 Make sure that the emulator is configured with a storage card. You can also check File.ExternalWritable to determine whether a writable external storage is available. Upvote 0
Make sure that the emulator is configured with a storage card. You can also check File.ExternalWritable to determine whether a writable external storage is available.