Android External Storage among mobile brands

I ran into an interesting problem. I found that Samsung in its own Android phones has two storage implementations.

1st: / sdcard - internal memory and / sdcard / external _sd - actually inserted memory card

2nd: / storage / sdcard0 - internal memory and / storage / ExtSdCard - actually inserted memory card.

My application needs data to be stored on the SD card, so I ran into a problem how to determine which folder can be a link to the SD card or not. Do you know the situation with any other Android manufacturer (LG, HTC, Sony), how to deal with external SD-cards and how they are visible in the Android system?

+4
source share
1 answer

It's really that simple. When you view your samsung mobile phones, this is an internal storage that acts like your SD card.

if you want to save the file to Sdcard, you need to stop hard-coding the path, for example,

/mnt/sdcard.. and so. 

use Environment.getExternalStorageDirectory(); instead Environment.getExternalStorageDirectory();

This will return the path to your SD card immediately.

And from there add Environment.getExternalStorageDirectory()+File.separator+"your directoryname";

And it works for all brands not unique to Samsung.

+1
source

Source: https://habr.com/ru/post/1441194/


All Articles