getting file not found exception

后端 未结 3 920
不知归路
不知归路 2020-12-21 02:47

I have my android activity :

try {  
            File root=Environment.getExternalStorageDirectory();  
            Log.i(\"root\",root.toString());  
            


        
相关标签:
3条回答
  • 2020-12-21 03:30

    In Android 6 (Marshmallow) I had to explicitely check whether my app has permission "WRITE_EXTERNAL_STORAGE"

    0 讨论(0)
  • 2020-12-21 03:48

    Not sure but please verify that there exists External Storage in your emulator or phone otherwise it will through exception.

    0 讨论(0)
  • 2020-12-21 03:49

    Try this,,it works for me

    // create a File object for the parent directory
    File wallpaperDirectory = new File("/sdcard/Wallpaper/");
    // have the object build the directory structure, if needed.
    wallpaperDirectory.mkdirs();
    // create a File object for the output file
    File outputFile = new File(wallpaperDirectory, filename);
    //now attach OutputStream to the file object, instead of a String representation
    
    FileOutputStream fos = new FileOutputStream(outputFile);
    

    GO through this for more details

    0 讨论(0)
提交回复
热议问题