Application not able to access SD card when WRITE_EXTERNAL_STORAGE permission is granted at run time

后端 未结 2 1330
无人及你
无人及你 2020-12-19 18:09

In android M to access sdcard has to force stop and start app manually when permission is granted at runtime, how to achieve it programmatically?

H

2条回答
  •  醉梦人生
    2020-12-19 18:36

    You can below condition to check whether SDCard is available or not

    if (android.os.Environment.getExternalStorageState().equals(
            android.os.Environment.MEDIA_MOUNTED)) {
    
     //Check for the file
     File appFolder = new File(Environment.getExternalStorageDirectory() + File.separator
                + context.getString(R.string.app_name));
    
     boolean exist = appFolder.exists();
    }
    

提交回复
热议问题