The device requires external storage, but I do not have an SD card

Samsung Galaxy S3 without SD card, I use this code to check storage conditions.

Using this code:

boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media mExternalStorageAvailable = true; mExternalStorageWriteable = false; } else { // Something else is wrong. It may be one of many other states, but all we need // to know is we can neither read nor write mExternalStorageAvailable = mExternalStorageWriteable = false; } 

So, maybe someone can explain to me if for some reason this phone considers the internal memory as external? Or what?

+2
source share
3 answers

getExternalStorageDirectory does not always return an SDCard.

A Google doc says:

β€œdo not confuse the wordβ€œ external ”here. This directory can be better considered as media / shared storage. It is a file system that can store a relatively large amount of data and share all applications (does not apply permissions). Traditionally, this is SD, but it can also be implemented "as built-in storage in a device that is different from secure internal storage and can be mounted as a file system on a computer."

It is likely that "/ mnt / sdcard" refers to the built-in storage for your phone.

It is better to check the return path using the getExternalStorageDirectory method, whether it is external removable storage or not.

You can use Environment.isExternalStorageRemovable () to check it.

+12
source

Android will always report one mounted hardware memory (if any) as external storage.

This memory may be:

  • installed inside the device by the manufacturer (internal memory)
  • can be an SD card (external memory)

A device may even have both, but Android will only report one of them (mostly internal).

An easy way to get what is installed is where the adb shell mount .

 rootfs on / type rootfs (ro) tmpfs on /dev type tmpfs (rw,nosuid,mode=755) devpts on /dev/pts type devpts (rw,mode=600) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) tmpfs on /mnt/asec type tmpfs (rw,mode=755,gid=1000) tmpfs on /mnt/obb type tmpfs (rw,mode=755,gid=1000) /dev/block/mtdblock2 on /system type yaffs2 (ro) /dev/block/mtdblock3 on /data type yaffs2 (rw,nosuid,nodev) /dev/block/mtdblock1 on /cache type yaffs2 (rw,nosuid,nodev) /dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) /dev/block/vold/179:1 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) 
+1
source

Use this code to find out if there is a memory card in it:

 Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); if(isSDPresent) { // yes SD-card is present } else { // Sorry } 
0
source

All Articles