Reputation: 1949
I've created a file in my code, as shown below
FileOutputStream fOut = openFileOutput("samplefile.txt", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(text);
osw.flush();
osw.close();
Now, I know that the file is getting created because I can read the file when I do this:
FileInputStream fIn = openFileInput("samplefile.txt");
InputStreamReader isr = new InputStreamReader(fIn);
char[] inputBuffer = new char[text.length()];
isr.read(inputBuffer);
String readString = new String(inputBuffer);
System.out.println(readString);
So the text is getting read back. However, I can't find the file on my device. Where does it go?
Thanks in advance.
Upvotes: 2
Views: 1090
Reputation: 3571
The file is being saved to internal storage (see this link).
You can retrieve the path of the file with getFilesDir()
(see this link).
The path is /data/data/yourapplicationpackagename/files.
Upvotes: 2
Reputation: 1407
You can get the address of it be below line Code
File file = getFileStreamPath("samplefile.txt");
And for print it
String s = file.getAbsolutePath();
Upvotes: 3
Reputation: 44813
If you googled you could find this site link
which mentions
Android allows to persists application data via the file system. For each application the Android system creates a data/data/[application package] directory.
Upvotes: 1