I work on an sqlite3-based application designed only for myself. The problem is how not to rewrite a db-file after reinstallations of an apk-file? (I do not want to use an on-line database which would solve my problem.)
I already use this bit, so that the db-file on the computer would not get to the phone. build.settings
excludeFiles =
{
-- Exclude unnecessary files for each platform
all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", "*.db"},
android = { "LaunchScreen.storyboardc", },
},
But if I install the app again, the db-file which was on the previous version is removed completely.
Another way is to store db-file somewhere before installation of a new copy of the app, and then move the file back to the app’s directory where it was stored. But my device is not rooted, so I got no access to any of those folders:
I see…
Since it is impossible to move a db-file from folder to folder, but possible to keep it after reinstallations, then I had to create a db-file programmatically. If I ever will need to move the data from that file to another device/file (which I do not plan in the nearest future), I will export data somewhere and import it again; no big deal. Thank you for the hint.
If you mean using “lfs” to access the default sandbox system folders. You can. See Solar2D “lfs” docs here.
local lfs = require( "lfs" )
-- Get raw path to the app documents directory
local doc_path = system.pathForFile( "", system.DocumentsDirectory )
for file in lfs.dir( doc_path ) do
-- "file" is the current file or directory name
print( "Found file: " .. file )
end
However, if you mean by external storage outside these sandbox system folders. By default, Solar2D cannot access files outside these sandbox system folders. For Android devices, you could, via plugins. Here are two possible plugins.