Android Question Saving and Loading a string between app runs.

HNICofCODE

New Member
Licensed User
D

Deleted member 103

Guest
have you read this tutorial yet?
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
in vb I would just do
IN VB:
my.settings
I searched all the terms I could come up with and I cant find an answer to this.
https://www.b4x.com/android/forum/threads/10608/#content
and
https://www.b4x.com/android/forum/posts/80837/
seemed to be close to what I am looking for but not exactly.

I need to be able to write a string to a variable that I can load and save on additional runs of my app.
Could someone please help me with that or point me in the right direction?
Thanks
 
Upvote 0

HNICofCODE

New Member
Licensed User
This was the avenue I ended up taking.
And I was able to get it to work.
Getting the library setup was a pain in the ass to understand but I muddled through it.
Thank you so much for your help and thank you to everyone else who also shared their methods.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I need to be able to write a string to a variable that I can load and save on additional runs of my app.
Based on your question in the first post, it seems the simplest way is to save the string to a file and retrieve it
when needed. KeyValueStore2 is good, but an overkill in this case:
B4X:
Dim s As String = "B4X Community"
    File.WriteString(File.DirInternal,"myfile.txt", s)
    
    Dim savedvar As String = File.ReadString(File.DirInternal, "myfile.txt")
    Log(savedvar)  'displays: B4X Community
 
Upvote 0
Top