How to find the internal (default memory for phones) and external storage (removable SD card) in Android?

My Motorola phone has 12 GB of internal memory and the ability to change Sd cards.

In the DDMS file explorer, my internal phone storage (12 GB) is installed as sdcard and my removable SD card is mounted as sdcard-ext .

Using the Environment.getExternalStorageDirectory () method . getAbsolutePath () , I can get the directory " / mnt / sdcard ". Is there any method by which I can find the absolute path for my removable SD card? ... that is, that will return me " / mnt / sdcard-ext "

+4
source share
2 answers

Currently, the Android platform only supports one mass storage device, so it’s difficult to manage several (you can try to parse /proc/mounts to get all mounted devices). But you can use the Motorolas API that they built because of this.

Check out the Motorola "External" Storage API .

+5
source

Try this code to return all storage folder name.

Mark my post here:

fooobar.com/questions/36365 / ...

Do not forget to add permission.

Accessing external storage

To read or write files to external storage, your application must have the READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE system permissions. For instance:

 <manifest ...> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ... </manifest> 
0
source

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


All Articles