getting file not found exception

后端 未结 3 994
不知归路
不知归路 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: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

提交回复
热议问题