How to create/write file in the root of the Android device?

Context.openFileOutput is meant to be used for creating files private to your application. they go in your app’s private data directory. you supply a name, not a path: “name The name of the file to open; can not contain path separators”.

http://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String, int)

as for your question, you can’t write to / unless you’re root:

my-linux-box$ adb shell ls -l -d /
drwxr-xr-x root root 2010-01-16 07:42
$

i don’t know what your API is that expects you to write to the root directory, but i’m guessing it’s not an Android API and you’re reading the wrong documentation 😉

Leave a Comment