Move files into a writable directory
You can have your program move files into a read-write (writable) directory.
If you create a flat file to hold all the files required by the app, a flat file is created on the mobile device. This is done by the default packaging nodes when you create a new BAM Mobile Project (.4pw).
Androidâ„¢
iOS
For your iOS applications, the directory created and holding the app files is a read-only directory. If writable files (such as a database file) need to be updated by the app, those files must be placed into a read-write directory on the device. Moving files from the read-only directory to a read-write directory is not something handled by packaging. You must handle it within your app.
- The
base.Application.getProgramDir()
method returns the base program directory, storing your compiled files, an initial database file, and so on. On an iOS device, this is a read-only directory. os.Path.pwd()
defines a writable directory for holding writable files, such as an error log or the user database.
At deployment, when your application initially starts, we recommend that you copy the writable
files from the application directory (using the function
base.Application.getProgramDir()
) to the current working directory (using the
function os.Path.pwd()
).
For an example, open the
OfficeStoreMobile demo project, open the
OrdersApp.4gl intermediate file, and look for the
OrdersApp_install
function. In this function, the
os.Path.copy
method is used to copy a database file from the
read-only source directory to the read-write destination directory.