I have finished creating an application but I cannot publish it since it packs wrong DB. I have a DB (local.db) which has replaced an older db in the files folder (Ctrl-C -> Ctrl-V in the files folder). When I try to create Release Version I can see in the phone that the old db is packed and installed. I tried to clean the project ---> Nope. I tried to remove the db from file (right click -> ...Delete File...) and add again the new db ---> Nope. It keeps packing and installing the wrong db. Anyone with relatives knowledge who wants to inform me why this is happening?
Edit - As I said the old db was deleted in the files folder (replaced) and I am able to see the contents of the new local.db in Files Folder which are the correct ones.
AND you ARE using this DB when the app runs the first time? Mean; copy the file to another place and use it from here.
Are you SURE you are copying the File before the use of it?
1. I have opened the Files folder and I see the file of about 500k (new one)
2. I have opened the APK with WinRar and I see in folder assets the same 500k file
3. I run the application and I see a 236k file which I copy to a windows folder and it is not the same.
4. I clear cash and I clear storage and I uninstall completely and run Release (Obfuscated) in B4A --> Nope again the old file. It has no logic.
Public Sub CopyDBFromAssets (FileName As String) As String
LogColor("CopyFromDBAssets " & FileName, Colors.Blue)
Dim TargetDir As String = GetDBFolder
If File.Exists(TargetDir, FileName) = False Then
LogColor("CopyFromDBAssets " & FileName, Colors.Red)
File.Copy(File.DirAssets, FileName, TargetDir, FileName)
End If
Return TargetDir
End Sub
I completely clear cache, clear storage and uninstall and then run the app. Nope --> the same 296k file appears. Only the blue appears so it did not copy.
I am thinking maybe it is a Samsung problem since I did not change anything in my code and it used to work perfect. So I do that. I close the app delete the file manually and start again the app. Blue and Red show. This time it is correct. If it is a code matter why does it work correctly the second time? BUT WAAAAAIIIIT!!! IT GETS EVEN BETTER!!! I am thinking maybe it was a matter of the Samsung phone and now that it copied the correct it will keep the correct. I clear the cache, clear storage, uninstall the app and do again the same thing (Install through B4A Debug). Only blue appears and the same 296k file shows up again. Can someone make out anything of this? What am I suppose to blame and why?
My best guess is the old DB exist on your phone and you have not written code to update it or delete it if version changes, hence its unable to copy the new DB from assets folder to your app directory.
Remove the app from your testing device and recompile, and run the app
Note that Android automatically makes a backup of installed apps. So even if you uninstall the app and then install it, previous files might be there.
You can disable auto-backups:
Note that Android automatically makes a backup of installed apps. So even if you uninstall the app and then install it, previous files might be there.
You can disable auto-backups: