سؤال

I am developing an android application and I need to know how could i check if the sdcard exist or not before exporting a file to it , so that i could notify the user that the sdcard is or isn't mounted.

هل كانت مفيدة؟

المحلول

public boolean hasSDCard() {
    return android.os.Environment.getExternalStorageState()
              .equals(android.os.Environment.MEDIA_MOUNTED);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top