I used the following code to store the file on Internal Storage in Application run on a device.
private void writeToFile(String s){
try { // catches IOException below
FileOutputStream fOut = openFileOutput("samplefile.txt",
MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(s);
osw.flush();
osw.close();
FileInputStream fIn = openFileInput("samplefile.txt");
InputStreamReader isr = new InputStreamReader(fIn);
char[] inputBuffer = new char[s.length()];
isr.read(inputBuffer);
String readString = new String(inputBuffer);
Log.i("String", readString);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
The logcat shows that the file is correctly written. But while trying to access the file on the device using FileExplorer on Eclipse the file isn't seen where it should be ("/data/data/your_project_package_structure/files/samplefile.txt"). I find the inner data folder as empty. What went wrong?
I want to read that file and get the data to feed another application written in python. Is it possible?
P.S: I am testing the application on a device and not on emulator.