I want to create some pre-created files when my Android application is installed.
I would like to create the file in both the internal memory (data/data//files/) and in a newly created sdcard directories (/sdcard//data1/).
How can I do this?
If your phone's web browser doesn't give you the option to open the file after downloading, open your file explorer app, go to the Downloads folder on your device, then tap the APK file. Allow the app any required permissions it asks for. Then, at the bottom of the installer window, tap Install.
apk? For normal apps, there are stored in internal memory in /data/app. Some of the encrypted apps, the files are stored in /data/app-private. For apps stored in the external memory, files are stored in /mnt/sdcard/Android/data.
On devices that run Android 9 (API level 28) or lower, your app can access the app-specific files that belong to other apps, provided that your app has the appropriate storage permissions.
If you have a larger number of files and a directory structure you should use /assets. These are not given any R-constants and can be scanned by your application
To open an asset-fil:
InputStream is = getAssets().open("path/file.ext");
To list a directory:
String[] files = getAssets().list("");
You can save you files in \res\raw
and write the code to store this files to the desired locations if it does not exist when the app start.
Check this to access the internal memory and sdcard
and access the raw
file using the following
InputStream databaseInputStream = getResources().openRawResource(R.raw.yourfile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With