I created an Android app which is storing some info on the database. I copied .apk file to a folder, clicked on it, it was installed and the app is working. But I cannot find in which folder the app is is located - I want to backup the database. Any ideas?
Thanks,
zb
The app will normally be installed in /data/app directory - it would usually be just the copy of your APK, although not always. The databases, unless you explicitly specified a different location in your code, will be in
/data/data/your.package.name/databases
The package name will be something like com.yourcompany.appname.
Note that backing the data by copying the databases is not the right way to backup your files. Use android backup instead. Also, unless your phone is rooted, you may not be able to get to these databases.
Zalek
Here the location for the app to be searched
MyApp/myapp/build/outputs/apk/myapp-debug.apk
Note: "MyApp" is your project name of your app. I just take an example as myapp
Related
I've created an app using Android Studio and it has a database file handler. I've gone through a few post and everywhere they are saying go to data\data\ folder to get the app folder. But mine doesn't show any folder for my app. Do I have to manually set this file location to be created? How can I find my database.db file?
It should be automatically placed in data/data/databases in your app folder unless you specify otherwise. Are you sure it is created?
That is /data/data/package-name/databases/dbfilename
I have another suggestion. If you have enabled backup for your application, you might be able to use ADB BACKUP, like suggested here: http://blog.shvetsov.com/2012/09/backup-your-android-without-root-or.html
The database files are located in the following folders.
/data/data/packagename/databases/
You can access the .db file only on emulator, its not possible on actual device. In the android studio open the DDMS perspective, there on the left hand side you will find the storage structure, there in data/data/ you will get the file you are looking for
I use SQLite as my offline database. After the APK installation, I couldn't find the folders that I made. I want to put the database in device Storage : /storage/emulated/0 (Samsung device where I tested my program).
I already put this in my manifest :
<manifest android:installLocation="preferExternal" />
To install APK, i copied it directly from bin to my phone external storage. Did I miss something?
**notes: I need for users to be able to access files (.TXT and .XML) from device storage, so the folders and files inside shouldn't be hidden.
I'd appreciate your kind reply.. Thanks
installLocation="preferExternal" refers to the app installation, not to an eventual database (which I don't see mentioned anywhere in your question, other than in its title).
i copied it directly from bin to my phone external storage. Did I miss something? YES: this is not enough.
You have to install the apk, after copying it - you'll need a file manager to launch it.
OR (better) activate your Debug Options and run the app from the IDE directly onto your phone (you'll need to install the ADB Bridge, aka USB driver, aka ADB Composite Interface).
so the folders and files inside shouldn't be hidden. Every file in the apk is private to your app.
Other than this, your SD Card and then use them from there.
Use Environment.getExternalStorageDirectory() to get the path to your SD Card.
If you need some clarification on databases, please post a specific question about that matter.
I want to store music files downloaded from server in my application installation directory. I noticed that several android phones has different path to application installationo directory.
Such as Android/data, data/data and etc.
I develop the application with phoengap. I checked their api but coudnt get a methode that return application installaitn folder path.
Can anybody help me on this?
thanks
Due to security reasons, you cannot write to application install or the assets directory, instead you can write files in application data folder.
http://cordova.apache.org/docs/en/2.9.0/cordova_file_file.md.html
I have developed an Android app using Appcelerator Titanium. This app will create a file in applicationDataDirectory and install a database as well.
If run on emulator, I can locate those files using "adb" command. But how about on Android device? Can I use the "My Files" app to view those file I created? (since I can see files created by other application there.)
Moreover, I expect once I removed the app on device, it will automatically remove the related files and database. Is that true?
Because I found that even I removed the app from the device, the database seems left behind. I can tell because after deleting app and re-run on device(from Titanium), it show previous data.
I am using Ti SDK 2.0.1GA2, Android Runtime V8. And using Samsung Galaxy Tab for testing.
Thanks in advance.
Application Private Data files are stored within <internal_storage>/data/data/<package>
Files being stored in the internal storage can be accessed with openFileOutput() and openFileInput()
When those files are created as MODE_PRIVATE it is not possible to see/access them within another application such as a FileManager.
On Android 4.4 KitKat, I found mine in:
/sdcard/Android/data/<app.package.name>
Use Context.getDatabasePath(databasename). The context can be obtained from your application.
If you get previous data back it can be either a) the data was stored in an unconventional location and therefore not deleted with uninstall or b) Titanium backed up the data with the app (it can do that).
You can get if from your document_cache folder, subfolder (mine is 1946507). Once there, rename the "content" by adding .pdf to the end of the file, save, and open with any pdf reader.
This is a simple way to identify the application related storage paths of a particular app.
Steps:
Have the android device connected to your mac or android emulator open
Open the terminal
adb shell
find .
The "find ." command will list all the files with their paths in the terminal.
./apex/com.android.media.swcodec
./apex/com.android.media.swcodec/etc
./apex/com.android.media.swcodec/etc/init.rc
./apex/com.android.media.swcodec/etc/seccomp_policy
./apex/com.android.media.swcodec/etc/seccomp_policy/mediaswcodec.policy
./apex/com.android.media.swcodec/etc/ld.config.txt
./apex/com.android.media.swcodec/etc/media_codecs.xml
./apex/com.android.media.swcodec/apex_manifest.json
./apex/com.android.media.swcodec/lib
./apex/com.android.media.swcodec/lib/android.hidl.memory.token#1.0.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_common.so
./apex/com.android.media.swcodec/lib/android.hardware.graphics.mapper#2.0.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_vorbisdec.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_h263dec.so
./apex/com.android.media.swcodec/lib/libhidltransport.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_h263enc.so
./apex/com.android.media.swcodec/lib/libcodec2_vndk.so
./apex/com.android.media.swcodec/lib/android.hardware.graphics.mapper#2.1.so
./apex/com.android.media.swcodec/lib/libmedia_codecserviceregistrant.so
./apex/com.android.media.swcodec/lib/libhidlbase.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_aacdec.so
./apex/com.android.media.swcodec/lib/libcodec2_soft_vp9dec.so
.....
After this, just search for your app with the bundle identifier and you can use adb pull command to download the files to your local directory.
I have an app that allows exporting files to a non-standard folder on the device's file system.
I put the exports in a folder separate from the application data, because I want the user to be able to navigate to the files using a file-system explorer, and the application data folders/files are not accessible that way.
However, when the application is uninstalled, those non-application-data folders, the folders separate from the application-data file structure, are left behind.
Is there anyway to call an uninstall script, and if so, how is the script called/executed when uninstalling through Android Market or through the device's uninstall in the settings for 'Manage Applications'?
Intent.ACTION_UNINSTALL_PACKAGE
I believe this should work for you. Unfortunately, it's for API 14. I don't know it that falls into your needs.