Question

I can write a file to local storage of my (Samsung) tablet, with code like this:

String fileName = "myfile.ser";
FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(this);
os.close();

Reading is no problem either with similar code. I can see the file system in Windows explorer of the attached tablet via USB. But I cannot discover where on the Android file system the file "myfile.ser" is written?

Is it hidden?

Was it helpful?

Solution

openFileOutput returns a location not accessible trough file explorer. It should be /data/data/yourpackagename

OTHER TIPS

According to this questions What file system path is used by Android's Context.openFileOutput()?

The openfileoutput() methods points to the directory returns by getFilesDir() on Context...

It should be indeed /data/data/yourpackagename ...

openFileOutput() gets the base directory from getFilesDir() from your application context. The path as mentioned is /data/data/yourpackagename.

The apps are sandboxed which means the files relevant to an app are available in the apps own sandbox unless saved on external storage. The data directory is internal to the os and even if you use DDMS you will not be able to browse the data directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top