Jenney
Jenney

Reputation: 11

Android device file explorer: Error opening contents of device file: Remote object doesn't exist

I tried to write a string in a text file and store it in the SD card of the emulator. It seems successful. But when I double-clicked to open or copy the saved file in Device File Explorer, it shows an error: Error opening contents of device file "myTestFile.txt": Remote object doesn't exist!.

String toSaveString = "hihi";
        if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
            try{
                File f = new File(getExternalFilesDir(null),"myTestFile.txt");
                FileOutputStream outStream = new FileOutputStream(f, true);
                PrintWriter writer = new PrintWriter(outStream);

                writer.println(toSaveString);

                writer.close();
                outStream.close();

                Log.d("FileLog","File Saved: "+f.getPath());
            }catch(IOException e){
                e.printStackTrace();
            }
        }else{
            Log.e("FileLog","SD card not mounted");
        }

Are there any ways to open the file? Thank you!

Upvotes: 1

Views: 931

Answers (0)

Related Questions