I need several files to be in the internal directory of my Android app on installation.
I could theoretically just copy them from the assets folder but that is not really convenient.
The files would be to store settings and progression.
How could I create these files?
As mentioned in the comments, during installation, the device does nothing but simply copy the app itself. If you want to do anything else, that's the job of your application.
Use local storage for this purpose (will be deleted on uninstall, on the desktop target, this is the same as internal
.)
You could either:
This is the more reliable choice, as in the (rare?) case that the files are deleted, they will be replaced.
@Override
public void create() {
...
for (String file : filesToCopy) {
final FileHandle handle = Gdx.files.local(file);
if (!handle.exists()) {
// copy to handle
}
}
}
You can use Preferences
for this:
@Override
public void create() {
...
final Preferences prefs = Gdx.app.getPreferences("prefs");
if (prefs.getBoolean("newInstall", false)) {
for (String file : filesToCopy) {
final FileHandle handle = Gdx.files.local(file);
// copy to handle
}
}
prefs.putBoolean("newInstall", true);
prefs.flush();
}