Using a virtual sdcard in the Emulator
filed in Android, HowTo on Jan.22, 2009
To be more in sync with the actual Android target hardware you need access to an “sdcard” right from inside the Emulator. Right out of the box the Emulator does not provies this feature but a solution is only a few minutes away. The following steps are for Mac OSX. In case you are running Linux or that other OS you need to change the path info accordingly. That should be the only difference though.
1.) Build the sdcard image file
The Android SDK provides a tool to generate an sdcard image file. The image itself will have FAT32 format which is in line with the real sdcard used on current G1 hardware. Go to the “tools” path or start the “mksdcard” utility from anywhere using the complete path:
mksdcard -l sdcard 128M /Users/yourname/Documents/Android/sdcard.img
This will generate the image file with the name “sdcard.img” in your personal Documents folder. The image size is 128 Mbyte and the (optional) sdcard label is “sdcard”.
2.) Change the Emulator “Command Line Options”

Now since we got the sdcard done and waiting to be used let’s inform the Emulator to use it. The step needed is to adjust the Run/Debug Configuration inside of Eclipse. Select “Run| Open Run Dialog …” or  Run| Open Debug Dialog …”. Then select the “Target” tab. Now you will be able to add the sdcard option to the  ”Additional Command Line Options”:
-sdcard /Users/jfey/Documents/sdcard.img (use your path of cause)
Press “Apply” and “Run” or “Debug”. make sure to have close any old emulator instance first though.
Leave a Reply