Put files in dirdefaultexternal on install?

PaulR

Active Member
Licensed User
Longtime User
Hi

I have an ini file and user configurable config files that I want to install along with my app in dirdefaultexternal. The ini file isn't an issue because I am creating that if it doesn't exist, then reading from it.

The config files contain many more parameters and so I would (much) rather have the installation cover this by including existing files.

Is this possible?

Paul
 

admac231

Active Member
Licensed User
Longtime User
You could use a flag file to check for a previous install and if not copy all file from assets.

So say you have 20 files. Create another one called install.dat. Have all of these in the project assets and in Main Activity_Create check to see if the install.dat file exists. If not, copy the default files from the asset folder.

You can loop through all the files in the folder pretty easily, like so:
B4X:
   If File.Exists(File.DirDefaultExternal,"install.dat") Then
      'Previously been installed
   Else
      Dim files As List
      files = File.ListFiles(File.DirAssets)
      For i = 0 To files.Size - 1
         File.Copy(File.DirAssets,files(i),File.DirDefaultExternal,files(i))
      Next i
   End If
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
This line should be:
B4X:
File.Copy(File.DirAssets, files.Get(i), File.DirDefaultExternal, files.Get(i))

files is a List not an array. ;)

However, copying ALL files from Assets will copy some unnecessary files, some kind of filtering should be in place.
 
Upvote 0
Top