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

给你一囗甜甜゛ 提交于 2019-12-01 06:20:44

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5715556/cant-find-the-file-stored-on-internal-storage-of-device-on-file-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!