سؤال

I have an Android application which needs some data from the SD and I check on entry that the files are there with File.exists() method and checking the SD card isnt either UNMOUNTED or SHARED. This works fine on my device, but have gotten feedback that on other device its showing the Toast that indicates that no data is present.

My questions are:

1 - Is there a way this checks can indicate that the SD is not mounted or shared even after it has been unplugged from the PC?.

2 - Is it possible that getExternalStorageDirectory() resolves to internal storage? I know how this sounds, but people have told me that the app works on some devices when copying the data to internal storage instead of external one, even though i keep telling them that shouldn't happen.

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

المحلول

On many devices getExternalStorageDirectory() does not give you the SdCard but resolves to internal storage often called /sdcard or /storage/sdcard0. It does not matter if you put a microSD in the device. Those paths stay the same and are valid.

If you put in a microSD than that can be mounted under many names e.g:

               , "/mnt/sd-ext
               , "/mnt/sdcard-ext
               , "/mnt/external_sd
               , "/mnt/extsd
               , "/mnt/extSdCard
               , "/mnt/sdcard2

There is no function to determine the sdcard. You have to give your users the opportunity to select the storage directory.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top