Posts Tagged ‘media card’

How to create and use the SD Card with the Android Emulator

Tuesday, November 11th, 2008

By default the Android emulator does not have an SD card enabled. I was looking for this while I tried to save some images which I viewed on the Android browser within the emulator. The emulator told me that it can not download / save the image because there is no SD card installed. Well, I would also save this on the phone’s memory … but it seems the emulator / Android OS does not like that.

However, enabling the SD card is compared to other device simulators quite cumbersome but it works and if you did it once it is pretty easy though. In the end it is a runtime configuration (additional parameter) to start the emulator with an SD card image file. So this needs to be done just once for each runtime / debug configuration in Eclipse. I just made that and it works fine. As I am using Mac OS X & Eclipse the following examples are for this platform. If you are running Linux or Windows you might need to adjust the paths but it should be fairly easy.

1. Create an SD card image file

In the command line you just enter the following commands:

$ cd /Developer/android-sdk-mac_x86-1.0_r1/tools/

$ ./mksdcard 256M /Users/YOUR_USER_NAME/Documents/workspace/android_sdcard

You can now check if the file has been created but if there is no error it should be there. You can also adjust the size if you want to have a smaller SD card image or even a bigger one. 😎

2. Tell your Android emulator you want to start with that SD card image file

Therefor, go to: “Debug » Debug Configurations… » [select or create an Android Application debug configuration] » Target” and enter at “Additional Emulator Command Line Options” the following:

-sdcard /Users/YOUR_USER_NAME/Documents/workspace/android_sdcard

Unfortunately, the Android debugger setup (at least in SDK 1.0 R1) does not take eclipse variables like ${workspace_loc} and therefor we need the full path in here. Anyway, this might look like:

How to create and use the SD Card with the Android Simulator

That’s it. Hit “Apply” and then “Debug” to start the emulator with your SD card.

Note: If your emulator is still running from the last test please close it first.