A AymanA Active Member Licensed User May 4, 2019 #1 Hi Helpers I have a sqlite db with multiple tables, I am not sure why but I no matter what I do, I can not read from all the tables in my DB, I have searched in sqlite documentation and saw some examples which are not different than what I have, but for some reason it fails, when I try the code below it returns an error: Code: Sub subGroupRetrieve() grouplist.Initialize() Starter.myCUR = Starter.mySQL.ExecQuery("SELECT distinct topicsplit.groupname FROM topicsplit") For i= 0 To Starter.myCUR.RowCount - 1 Starter.myCUR.Position = i grouplist.Add(Starter.myCUR.GetString("groupname")) Next end sub Error in log: Code: android.database.sqlite.SQLiteException: no such table: topicsplit (code 1 SQLITE_ERROR[1]): , while compiling: SELECT distinct topicsplit.groupname FROM topicsplit There is topicsplit as you can see from the compressed sample attached. I really appreciate your help on this! Attachments sqlite_multi_tbl.zip sqlite_multi_tbl.zip 9.7 KB · Views: 578
Hi Helpers I have a sqlite db with multiple tables, I am not sure why but I no matter what I do, I can not read from all the tables in my DB, I have searched in sqlite documentation and saw some examples which are not different than what I have, but for some reason it fails, when I try the code below it returns an error: Code: Sub subGroupRetrieve() grouplist.Initialize() Starter.myCUR = Starter.mySQL.ExecQuery("SELECT distinct topicsplit.groupname FROM topicsplit") For i= 0 To Starter.myCUR.RowCount - 1 Starter.myCUR.Position = i grouplist.Add(Starter.myCUR.GetString("groupname")) Next end sub Error in log: Code: android.database.sqlite.SQLiteException: no such table: topicsplit (code 1 SQLITE_ERROR[1]): , while compiling: SELECT distinct topicsplit.groupname FROM topicsplit There is topicsplit as you can see from the compressed sample attached. I really appreciate your help on this!
mc73 Well-Known Member Licensed User Longtime User May 4, 2019 #2 Possibly, you have an old db at dir.internal from which this table is missing. Try deleting this db and reload your new one from assets. Upvote 0
Possibly, you have an old db at dir.internal from which this table is missing. Try deleting this db and reload your new one from assets.
klaus Expert Licensed User Longtime User May 4, 2019 #3 Just to confirm. It works OK for me. So the suggestion of mc73 will solve the provlem. Upvote 0
A AymanA Active Member Licensed User May 4, 2019 #4 @mc73 @klaus thank you so much for confirming that it is working for you!! Appreciate your help! I have been scratching my head for a very long time thinking I was doing something wrong! I am sorry I didn't get the part of dir.internal I think you mean to remove the app on the mobile which will remove the db file right? If no then can you explain more to learn from this. Thank you so much for your help guys! Upvote 0
@mc73 @klaus thank you so much for confirming that it is working for you!! Appreciate your help! I have been scratching my head for a very long time thinking I was doing something wrong! I am sorry I didn't get the part of dir.internal I think you mean to remove the app on the mobile which will remove the db file right? If no then can you explain more to learn from this. Thank you so much for your help guys!
klaus Expert Licensed User Longtime User May 4, 2019 #5 In the Starter Service, in the SaveDB routine add the line to delete the file from File.DirInternal. Code: Sub SaveDB() File.Delete(DBDir, DBName) If File.Exists(DBDir, DBName) = False Then File.Copy(File.DirAssets, DBName, DBDir, DBName) End If End Sub And when it works don't forget to comment this line. Last edited: May 5, 2019 Upvote 0
In the Starter Service, in the SaveDB routine add the line to delete the file from File.DirInternal. Code: Sub SaveDB() File.Delete(DBDir, DBName) If File.Exists(DBDir, DBName) = False Then File.Copy(File.DirAssets, DBName, DBDir, DBName) End If End Sub And when it works don't forget to comment this line.
A AymanA Active Member Licensed User May 5, 2019 #6 It worked!!, I really appreciate your help on this and the time you have spent to help me out! thank you so much! Just to understand, the File.DirInternal is the directory that is created with the application, and it it is specific for the app running, so removing the app and reinstall it (through the B4A Bridge / Debug mode) in my assumption deletes the directory, or this is an incorrect assumption? Upvote 0
It worked!!, I really appreciate your help on this and the time you have spent to help me out! thank you so much! Just to understand, the File.DirInternal is the directory that is created with the application, and it it is specific for the app running, so removing the app and reinstall it (through the B4A Bridge / Debug mode) in my assumption deletes the directory, or this is an incorrect assumption?
Computersmith64 Well-Known Member Licensed User Longtime User May 5, 2019 #7 AymanA said: It worked!!, I really appreciate your help on this and the time you have spent to help me out! thank you so much! Just to understand, the File.DirInternal is the directory that is created with the application, and it it is specific for the app running, so removing the app and reinstall it (through the B4A Bridge / Debug mode) in my assumption deletes the directory, or this is an incorrect assumption? Click to expand... If you are just rebuilding the app & running it in debug mode, then no - the app is not removed, nor is Dir.Internal. If you actually uninstall the app, then compile, install & run it, then Dir.Internal will be removed with the uninstall & recreated with the new install. - Colin. Upvote 0
AymanA said: It worked!!, I really appreciate your help on this and the time you have spent to help me out! thank you so much! Just to understand, the File.DirInternal is the directory that is created with the application, and it it is specific for the app running, so removing the app and reinstall it (through the B4A Bridge / Debug mode) in my assumption deletes the directory, or this is an incorrect assumption? Click to expand... If you are just rebuilding the app & running it in debug mode, then no - the app is not removed, nor is Dir.Internal. If you actually uninstall the app, then compile, install & run it, then Dir.Internal will be removed with the uninstall & recreated with the new install. - Colin.
Erel B4X founder Staff member Licensed User Longtime User May 5, 2019 #8 Computersmith64 said: If you are just rebuilding the app & running it in debug mode, then no - the app is not removed, nor is Dir.Internal. If you actually uninstall the app, then compile, install & run it, then Dir.Internal will be removed with the uninstall & recreated with the new install. Click to expand... This is not 100% correct. On newer versions of Android, the app might be backed up automatically and then the previous files will be restored. You can disable it with: Code: 'manifest editor SetApplicationAttribute(android:allowBackup, "false") Upvote 0
Computersmith64 said: If you are just rebuilding the app & running it in debug mode, then no - the app is not removed, nor is Dir.Internal. If you actually uninstall the app, then compile, install & run it, then Dir.Internal will be removed with the uninstall & recreated with the new install. Click to expand... This is not 100% correct. On newer versions of Android, the app might be backed up automatically and then the previous files will be restored. You can disable it with: Code: 'manifest editor SetApplicationAttribute(android:allowBackup, "false")
Computersmith64 Well-Known Member Licensed User Longtime User May 5, 2019 #9 Erel said: This is not 100% correct. On newer versions of Android, the app might be backed up automatically and then the previous files will be restored. You can disable it with: Code: 'manifest editor SetApplicationAttribute(android:allowBackup, "false") Click to expand... True - I forgot about that... You can also disable cloud backup in the device settings. - Colin. Upvote 0
Erel said: This is not 100% correct. On newer versions of Android, the app might be backed up automatically and then the previous files will be restored. You can disable it with: Code: 'manifest editor SetApplicationAttribute(android:allowBackup, "false") Click to expand... True - I forgot about that... You can also disable cloud backup in the device settings. - Colin.
A AymanA Active Member Licensed User May 5, 2019 #10 Perfect! now I understand the cause of this thank you for your help! it is really great to have awesome people that tends to help, without this invaluable forum I could have struggled in so many ways Upvote 0
Perfect! now I understand the cause of this thank you for your help! it is really great to have awesome people that tends to help, without this invaluable forum I could have struggled in so many ways