Can't find the file stored on Internal Storage of Device on File Explorer
Asked Answered
K

1

3

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.

Kalakalaazar answered 19/4, 2011 at 11:22 Comment(1)
I have searched on stackoverflow where internal file stores in device.I have found here ("/data/data/your_project_package_structure/files/samplefile.txt") thanks primpop:)Erlina
K
2

On further research, I found that the files stored on the internal storage can be seen in file explorer only while using the emulator. So looks like I have to resort to external storage.

Kalakalaazar answered 19/4, 2011 at 11:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.