Ship settings file with apk

LittleBritaly

Member
Licensed User
Longtime User
I'd like to ship a settings.txt file in the root of the sd card, or failing that in the default installation folder (File.DirDefaultExternal) and would like a default one to be installed during installation.

I added the settings file in the IDE (bottom right, under files tab), expecting this to work, it doesn't (debug and release modes tried).

Am i missing something ?, I searched for an answer in the forum, but didn't find anything specific (maybe using wrong search term).

Thanks.
 

DouglasNYoung

Active Member
Licensed User
Longtime User
LittleBritaly,
What you need is something like -

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then 
      If File.Exists(File.DirDefaultExternal, "grj.db") = False Then
         File.Copy(File.DirAssets, "settings.txt", File.DirDefaultExternal, "grj.db")
      End If
   End If
        ' ..............................
End Sub

This will copy it into the default folder for your app which is probably the best place as its less likely to be touched by another app.

Cheers,
Douglas
 
Upvote 0
Top