The accepted answer does not work for me
Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
If the device has built-in storage, it returns true; My solution is that to check the number of files of external files, if there are several, the device has an SD card. It works, and I tested it for several devices.
public static boolean hasRealRemovableSdCard(Context context) { return ContextCompat.getExternalFilesDirs(context, null).length >= 2; }
Jemo Mgebrishvili Mar 06 '17 at 10:22 2017-03-06 10:22
source share