문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top