Skip to content Skip to sidebar Skip to footer

Where Do Files Get Saved In Android?

I am developing an application which writes some JSON data in a text file: FileOutputStream fOut; fOut = openFileOutput('myfile.txt', MODE_PRIVATE); OutputStreamWriter osw = new Ou

Solution 1:

It saves the file in /data/app_package_name/files folder. This location is inaccessible to user through file managers - only your app can access it through code.

Besides, if you are really eager to access the private files then you need to consider the option of rooting your device.

Solution 2:

Plugging it into your computer is mounting it to the SD card, usually. To save to that, get the SD card root directory File with Environment.getExternalStorageDirectory() and then construct a new File with that File and your desired string filename as the arguments. That will save it to your SD card which should be the first folder you see when you mount it on your computer.

By the way, for writing text/JSON straight to a file, just use FileWriter.

Solution 3:

You can not see the internal files visually until mobile is root. If you want to see it then store it in SD card.

Solution 4:

To save files to internal storage on Android (as of SDK 23) get your application's file storage location using getFilesDir() and save them there. The files should then be saved to /data/user/0/your.app.name/files. See: Saving Files.

Filefilename=newFile(getFilesDir(), "filename.txt");

Once written, you can retrieve this file from your computer using adb:

adb pull "/data/user/0/your.app.name/files/filename.txt"

Post a Comment for "Where Do Files Get Saved In Android?"