createNewFile - open failed: ENOENT (No such file or directory)

前端 未结 3 639
灰色年华
灰色年华 2020-12-10 11:41

I can\'t figure out what\'s going wrong here...I\'ve tried writing this more succicinctly, that didn\'t work. I put in all the extra strings after reading other suggestions

相关标签:
3条回答
  • 2020-12-10 11:58

    You are not using Environment.DIRECTORY_PICTURES correctly. It is not a folder by itself, you need to use it as a parameter to getExternalStoragePublicDirectory() method. Check here : http://developer.android.com/reference/android/os/Environment.html#getExternalStoragePublicDirectory(java.lang.String)

    0 讨论(0)
  • 2020-12-10 12:03

    Just change the begining of your code from this:

    public void outputBitmap(){ 
        String path = Environment.DIRECTORY_PICTURES.toString();
        File folder = new File(path + "/Blabla");
    

    To this:

    public void outputBitmap(){File folder = new File(getActivity().getExternalFilesDir(null) + IMAGE_DIRECTORY + "whatever you want for your directory name");
    
    0 讨论(0)
  • 2020-12-10 12:09

    Possible Issue:

    Make sure you have given following required permission in your manifest file.

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    

    And for Marhsmallow devices, make sure Contacts Groups Permissions is granted too by device user.
    Ref: http://developer.android.com/training/permissions/requesting.html

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