Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVD SD Card - External File

Im using the latest version of Android Studio and it won't allow me to add and external SD Card made with "mksdcard". In previous versions this was possible but now it just reverts to blank every time I try to add a new SD card.

Anyone face this problem or know how to fix?

enter image description here

like image 392
Mazz Avatar asked Jun 21 '17 02:06

Mazz


People also ask

How do I access my SD card on my emulator?

Yes, you can see the SD-card of emulator. Go to DDMS -> Click on Filer Explorer -> Mnt ->SD-card where you can see all your file. After allocating space you will be able to use that space as SD-card.

Can we simulate SD card in android?

You can create a disk image and then load it to the emulator at startup, to simulate the presence of a user's SD card in the device. To do this, you can use the android tool to create a new SD card image with a new AVD, or you can use the mksdcard utility included in the SDK.


2 Answers

One of the issues that the Android forgot to mention is with Android Studio 3.0 when you create AVD you need to now create an image for the SD CARD with the mksdcard tool to create a FAT32 disk image. After you use this tool then when you are creating the AVD you will see under advanced view the SD CARD area the External files click that and navigate to where you stored the sdCard.img file you created with mksdcard tool. Here is a bonus trick USE WITH CAUTION you can tell that emulator that it has the SD CARD ejected by changing this value hw.sdCard=yes in its config.ini file from yes to no. How to find the config.ini file

Windows Explore find the android/avd/device name open the device name file then with a FILE EDITOR like Sublime Text make the change to hw.sdCard=no and do a SAVE AS I suggest you not use MS notepad to do this

like image 179
Vector Avatar answered Sep 20 '22 09:09

Vector


I was facing the same problem today and found your question here on SO.
I was able to solve this issue by finding the config.ini file of the AVD itself,
and by editing it manually (e.g. with Notepad). On my Windows 10 machine the file is this one.

C:\Users\peter\.android\avd\Nexus_5_API_25.avd\config.ini

In that file I had to manually edit the value of this property as follows.

sdcard.path=C:\Programs\Android\SD_Card_Image\SD_Card001.img

That seems to make Android Studio to not revert back to a blank external file name.

EDIT: The weird thing is that even you specify an external file for your SD card image (as opposed to a studio managed SD card), that doesn't mean the AVD is using this exact file which you specified. Seems it uses it just initially (for initialization). Then Android Studio creates a copy of the image file somewhere (inside the AVD folder it seems) and from there on it uses his own copy. That was quite a surprising behavior to me. I even find it buggy. If that's what's intended, then what is the purpose of having the option to specify an external file?

like image 43
peter.petrov Avatar answered Sep 22 '22 09:09

peter.petrov