Search code examples
androidandroid-9.0-pie

Android 9.0 - How to find if user has inserted a corrupted sd card?


Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED_READ_ONLY)//corrupted -sd card 

But whenever I insert a corrupted sd card, the status is always "mounted", is this approach wrong?


Solution

  • I solved it by finding whether the inserted card is read-only or not, by traversing the /proc/mounts file and checking whether read_options of sdcard's mounted_directory is read-only or read-write.