Other Do not make my mistake (SQLite)

aklisiewicz

Active Member
Licensed User
Longtime User
As newbie I was wotking on some SQLite App. I got to the point I have had several ListView activities, but onle one of them was working. I used Firefox plugin to manage SQLite records. Obviously I added some Parent/Child records to the database to have some workable data. IT was very strange that some of my data showed up one list and some data did not. Another words there were some tables which did not show any data or wrong data etc. It took me w hole day to figure out what was causing it, so perhaps a giving back to the community I just explain, so you do not make my mistake.

When you change your data manuall in a SQLite manager you need to remove and re-add your SQLite database file in FILES Tab. Once I did that everything is working as expected. For some reason B4A keeps reading old version of your database file. Perhaps there is another reason but at least now you know how to workaround this problem.

HTH - Arthur
 

Attachments

  • b4a_db.png
    b4a_db.png
    18.3 KB · Views: 189

devlei

Active Member
Licensed User
Longtime User
I think the new 'Sync' feature in Version 3.2 will prevent this. I don't think it does it automatically - you still have to click the Sync button, but don't have to delete then re-add. I have not used it yet so maybe some-one else can confirm this.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The IDE doesn't cache the files. However when you run your app in rapid debug mode the IDE tries to reuse the previous installed "shell" app. If you remove a file or add a file then the IDE knows that it needs to reinstall the shell app.

You can also press on Tools - Clean project.

The sync button simply updates the files list based on the folder content.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Also remember if you're using code like this, that you need to manage a new version of the DB being created.. otherwise the DB in the read/write area will remain in place and not be overwritten. It depends on what your App does and how you interact with the data used in it.

B4X:
    'Database hasn't been copied to read/write area
        If File.Exists(File.DirInternal,"themsc.db") = False Then
       

            'ToastMessageShow("Database hasn't been copied to read/write area",True)
            'Msgbox("Database hasn't been copied to read/write area","Debug")
       

            File.Copy(File.DirAssets,"themsc.db",File.DirInternal,"themsc.db")
        Else
            'Database is in the read/write area, check the db_ver matches the app_ver
            'ToastMessageShow("Database is in the read/write area",True)
            'Msgbox("Database is in the read/write area","Debug")
           

        EndIf
 
Upvote 0
Top