Android Question Sqlite DB brower Update and effect in B4A Project

WofaCle

Member
Good day everyone, i trust you all doing well,
When i update a table in my sqlite DB browser
how do i make the changes take in effect in my App in b4A

My special thanks to Mr. Erel for always been helpful to my question posted here
Gradually my app is almost done and can't wait to share it here. Thank you.
 

aeric

Expert
Licensed User
Longtime User
Good day everyone, i trust you all doing well,
When i update a table in my sqlite DB browser
how do i make the changes take in effect in my App in b4A

My special thanks to Mr. Erel for always been helpful to my question posted here
Gradually my app is almost done and can't wait to share it here. Thank you.
If you have added a file by copying to Files directory, it is Readonly. You need to copy the DB from Files.DirAssets to xui.DefaultDir or File.DirInternal.
 
Upvote 0

WofaCle

Member
Please i have added to app file folder and also inside B4A IDE i have also
Added it there and i use the Starter module over there i have copied file.DirAssets and
File.DirInternal
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Please i have added to app file folder and also inside B4A IDE i have also
Added it there and i use the Starter module over there i have copied file.DirAssets and
File.DirInternal
I use the db Browser; when I finish some edit, I click the button above called "Write Changes". That updates the db. Next time I Compile the project, the changes are shown.

Also I use the following trick to update:

Code:
If File.Exists(DBFileDir, DBFileName) = False Then     '*SSS When False: Lets DB Browser update

Log("db file does not exist")

        File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)

        Log("db copied")

    Else

        Log("db file does exist")

    End If


When: DBFileDir, DBFileName) =true: in my case, the updating fails.
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
After you made changes to the SQLite database in PC, replace the file in Files Manager tab.
In B4A, delete the old file and then copy the new file from DirAssets to DirInternal like the first time you copy the file.

B4X:
' Do this only once after updated the db from DB Browser
If File.Exists(xui.DefaultFolder, "database.db") Then
    File.Delete(xui.DefaultFolder, "database.db")
    File.Copy(File.DirAssets, "database.db", xui.DefaultFolder, "database.db")
End If
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
One last thing about my above post:
Try putting your IDE on Release in the upper right corner; the changes in Browser won't display if you are in debug mode. I actually leave mine in release mode most of the time.

Also my entry is not the entire sub. I can give the entire sub if needed. It starts:

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
Root.LoadLay
..................... and so on.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I use the db Browser; when I finish some edit, I click the button above called "Write Changes". That updates the db. Next time I Compile the project, the changes are shown.

Well , there's a wakeup call .
I do exactly the same.. but then removed the dB from the IDE file tab, then re-added it back ! Dohhh ??
 
Upvote 0

WofaCle

Member
Wow thank you all it working now but won't this be a problem like whenever i update the db browser database i have to remove the file and re upload it.... Anyway please if there's any other
Way round kindly to me a favor with video tutorial thank you
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Funny Jack,
I did the same thing yesterday. Removed the dB from IDE file tab and this morning it took 30 minutes to figure out why my app wouldn't compile. Finally I put it back. Thanks for the wakeup call.
Shelballs
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Aeric, I could be wrong, but perhaps he's laughing at himself not previously recognizing your suggestion before you made it.
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Wow thank you all it working now but won't this be a problem like whenever i update the db browser database i have to remove the file and re upload it.... Anyway please if there's any other
Way round
WofaCle, as I mentioned in post #5, I leave the word False as it is to enable future changes without delay. In other words, I never need to remove the file from the file tab in the IDE.

Now I must add that my app isn't published yet so perhaps that will make a difference when it is published.

Today 11/14/24 my app is published and all I mentioned here is satisfactory for the Google Play bots and so on.
 
Last edited:
Upvote 0
Top