Hi to all, i'm trying to initialize a db in File.dirInternal (copied from assets) but i got this error:
B4X:
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
This is the code i use:
B4X:
If File.Exists(File.DirInternal,DB_NAME) Then
sqlManager.Initialize(File.DirInternal,DB_NAME,False)
Else
File.Copy(File.DirAssets,DB_NAME,File.DirInternal,DB_NAME)
sqlManager.Initialize(File.DirInternal,DB_NAME,False)
End If
I think is right because is a shared sub that I use in all my projects... So i don't understand the issue.
File in assets exists. Also in DirInternal.. I know i can use DBUtils to copy file, but i need to understand why i'm getting this error
normally, i would suspect an issue with DB_NAME (eg, you spelled it wrong or there is a problem with case sensitivity - "A" vs "a"), but in this case if there was a problem with DB_NAME, your tests would have failed and you would have seen a different error. perhaps you did and didn't tell us...
so, if the problem is not with DB_NAME, it would seem to be with the db itself. is it sqlite for sure? did you create it? perhaps it's corrupt?
normally, i would suspect an issue with DB_NAME (eg, you spelled it wrong or there is a problem with case sensitivity - "A" vs "a"), but in this case if there was a problem with DB_NAME, your tests would have failed and you would have seen a different error. perhaps you did and didn't tell us...
so, if the problem is not with DB_NAME, it would seem to be with the db itself. is it sqlite for sure? did you create it? perhaps it's corrupt?
Now way to have a problem with dbname as i use it in every sub, so i'm sure there is not a problem with mispelling. I'm sure it is SQLite, i created it with SQLliteStudio.
I think it's not corrupted, maybe can be an issue with table
You are 100% that the name of your database are the same on your database file and everywhere on your code?
Are you sure you don't have any other instance open?
Are you sure that the folder you use is not read only?
Have you try to create another file inside that folder?
You are 100% that the name of your database are the same on your database file and everywhere on your code?
Are you sure you don't have any other instance open?
Are you sure that the folder you use is not read only?
Have you try to create another file inside that folder?
I think you need to upload your project if you can as Pendrush suggested. But, here is another suggestion, as if you need another one, did you try to delete the database from internal and then copy it back to internal from assets and initialize it on firsttime in internal. I hope I am not repeating a recommendation given in the posts above.
Pure guess: could it be due to version differences in SQLite? Android is notorious for being behind. Does the desktop version use a feature that the older SQLite can not deal with?
Hi, I wanted to add some statistics to my App and now have the problem, that it seems that "OVER" is not supported by B4A ?! SELECT Spieler, count(*) OVER (PARTITION BY spieler ORDER BY Spieler_Spieltag.ID_Spieltag) as Part_SUM from Spieler_Spieltag Executing the statement in "DB Browser for...
www.b4x.com
Please MDev, don't let us down. we are all eager to find out what you come up with. Watch, tomorrow Erel will blow by all our suggestions and give him the correct diagnosis.
I think you need to upload your project if you can as Pendrush suggested. But, here is another suggestion, as if you need another one, did you try to delete the database from internal and then copy it back to internal from assets and initialize it on firsttime in internal. I hope I am not repeating a recommendation given in the posts above.
Pure guess: could it be due to version differences in SQLite? Android is notorious for being behind. Does the desktop version use a feature that the older SQLite can not deal with?
Please MDev, don't let us down. we are all eager to find out what you come up with. Watch, tomorrow Erel will blow by all our suggestions and give him the correct diagnosis.
Finally, found the issue!!
The problem is in the DB, i've using a table with a colum named All, and seems that All is a restricted keyword in sqllite so we can't use it as column name
I was just going to post that I deleted the table called: progress and then it worked fine.
Also, you have columns in that table with data type as STRING. I have never seen that before. I usually put TEXT. Is STRING a valid data type in SQLite. Apparently, it is valid. You learn something every day.