Writing to the internal private storage in Android Writing to the internal private storage in Android android android

Writing to the internal private storage in Android


Try changing the following line:

File newfile = new File(this.getFilesDir() + "/data/files/", "sample.txt");

to:

File newfile = new File(this.getFilesDir() + "/","sample.txt");


Not a direct answer to your question, but nevertheless: I noticed that you don't want to store tons of data in your file. Would it be a sufficient alternative to use the Shared Preferences instead?

And perhaps even more interesting: does the problem occur even when you write to the Shared Preferences file instead?

http://developer.android.com/guide/topics/data/data-storage.html#pref


A physical device's /data/ directory is only available to the root user. Since the only realistic way to get this access on a physical device is to root the device, DDMS file explorer cannot get into this branch of the directory tree.

As to why the app will not write there, likely the issue is in the fact that I have signed the app with debug keys (not a big *NIX expert, but what appears to be the case here from my personal research).