Check if the SDCard is present, boolean is always true

前端 未结 7 1973
故里飘歌
故里飘歌 2020-11-29 05:42

In my splash screen, I want to check if the phone has a SDCard. The Boolean statement is beneath:

    Boolean isSDPresent = android.os.Environment.getExterna         


        
相关标签:
7条回答
  • 2020-11-29 06:04

    If you want to show whether sdcard is inserted or not then just copy-paste this code its working 100% for all Devices, code is here:

    File file = new File("/mnt/extSdCard");
             try
             {
             File list[] = file.listFiles();
             Toast.makeText(getApplicationContext(), "Yes sdcard is mounted, file count "+list.length, Toast.LENGTH_LONG).show();
             }
             catch(NullPointerException o)
             {
             Toast.makeText(getApplicationContext(), "Sorry no sdcard is mounted:", Toast.LENGTH_LONG).show();
             }
    
    0 讨论(0)
提交回复
热议问题