user1610075
user1610075

Reputation: 1641

Where created files go?

I'm creating a file world-readable using this instruction:

FileOutputStream fos = openFileOutput(filename.toString(), MODE_WORLD_READABLE);

file is created (i can see emulator's memory and file is there), but I can't find it on my device!! Where is it?

Upvotes: 0

Views: 65

Answers (2)

John Paul Moore
John Paul Moore

Reputation: 76

The file is located in /data/data/com.yourpackagename/files/filename.txt which is hidden unless the device is rooted. You can access the file by copying it from the directory where it is created.

From the command line:

To copy a file

adb -d shell 
run-as com.yourpackagename 
cat /data/data/com.yourpackagename/files/filename.txt > /sdcard/filename.txt

Alternatively for a SQLite database

cat /data/data/com.yourpackagename/databases/dbname.db > /sdcard/dbname.sqlite 

This solution will work without having to root the device.

Upvotes: 0

user370305
user370305

Reputation: 109237

In Application's Internal Storage.. by default /data/data/<package_name>/

Check this directory..

But if your device is non-rooted then you can not seen this file in DDMS -> FIle-Explorer.

For this you can try via commnad prompt using adb shell

If you want to just access files in your application then use,

getFilesDir()

Gets the absolute path to the filesystem directory where your internal files are saved.

Upvotes: 2

Related Questions