I can't understand why the answer to this isn't in the Android developer docs; I find them consistently frustrating.
Re the openFileOutput() method on the Context class to open a file for writing, what internal storage file path does it write to?
http://developer.android.com/reference/android/content/Context.html
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
Re the openFileOutput() method on the Context class to open a file for writing, what internal storage file path does it write to?
It points to where getFilesDir()
on Context
returns. You can tell this because the documentation says:
Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.
In DDMS, I found my file under:
data > data > your app id > files
You can retrieve that file path by calling Context#getFileStreamPath(String)
:
Returns the absolute path on the filesystem where a file created with
openFileOutput(String, int)
is stored.
It returns a File
, so then call File#getAbsolutePath()
.
So summing up:
context.getFileStreamPath(name).getAbsolutePath()
This file is written to a path relative to your app within the devices memory.
You may perhaps with ddms
peek at the location, but when you are using this Context.openFileOutput(), you should not care about any absolute path.
If you want to pass the file name around you should consider using external storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With