Android Question B4A What is the most convenient way to save APP settings?

xiaoyao

Active Member
Licensed User
Longtime User
B4A What is the most convenient way to save APP settings?
Is it similar to the Windows INI file or using SQLITE? For a very small amount of data, does it take up too much memory to use a database? If reading or writing is closed immediately, will the APP increase the memory?
Asked CHATGPT AI, he said:
In Java, there is no built-in class directly for reading and writing INI files. However, you can use the java.util.Properties class to read and write INI files because the structure of INI files is similar to Java's properties files.
 
Solution
File.Readmap is a way similar to reading ini file on Windows.
Here is ini file sample
B4X:
#Fri Nov 08 10:30:33 CST 2024
k1=abc
k2=123

Alexander Stolte

Expert
Licensed User
Longtime User
 
Upvote 0

teddybear

Well-Known Member
Licensed User
File.Readmap is a way similar to reading ini file on Windows.
Here is ini file sample
B4X:
#Fri Nov 08 10:30:33 CST 2024
k1=abc
k2=123
 
Upvote 0
Solution

xiaoyao

Active Member
Licensed User
Longtime User
File.Readmap is a way similar to reading ini file on Windows.
Here is ini file sample
B4X:
#Fri Nov 08 10:30:33 CST 2024
k1=abc
k2=123
some people have andriod version ini read /write jar lib,i don't khnow how to download
 
Upvote 0

xiaoyao

Active Member
Licensed User
Longtime User
json keys write/read to file,maybe it's fine,but it's need load all data for read.

INI IT'S ONLY FIND key,read in disk low io count
 
Upvote 0

xiaoyao

Active Member
Licensed User
Longtime User
(1) [class] FileProvider - share files | B4X Programming Forum
https://www.b4x.com/android/forum/threads/class-fileprovider-share-files.97865/
https://blog.csdn.net/danffer1985/article/details/137457442

https://developer.android.google.cn/training/secure-file-sharing/setup-sharing?hl=nb

how to read filebody from other app?
use this? Provider.GetFileUri(FileToSend)

s= File.ReadString ("content://com.example.myapp.fileprovider/myimages/demo.txt")
content://com.example.myapp.fileprovider/myimages/default_image.jpg

B4X:
Private Sub btnViewImage_Click
    Dim FileName As String = "b4a.png"
    File.Copy(File.DirAssets, FileName, Provider.SharedFolder, FileName)
    Dim in As Intent
    in.Initialize(in.ACTION_VIEW, "")
    Provider.SetFileUriAsIntentData(in, FileName)
    'Type must be set after calling SetFileUriAsIntentData
    in.SetType("image/*")
    StartActivity(in)
End Sub

Private Sub btnShareFile_Click
    Dim FileToSend As String = "Message.txt"
    File.WriteString(Provider.SharedFolder, FileToSend, "jaklsdjalksdjalskdjasld")
    Dim in As Intent
    in.Initialize(in.ACTION_SEND, "")
    in.SetType("text/plain")
    in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)
End Sub
 
Upvote 0

xiaoyao

Active Member
Licensed User
Longtime User
Please confirm that you want to mark this post as the solution.?
Forum technical help, set as correct answer
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Please create a new thread for new question.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…