Wednesday, September 21, 2011

how to emulate an SD card with the Android emulator


Here are the required step to use an SDCard :

1) Create the emulated SDCard on your real computer :


Google provides a tool just for that, in their SDK/tools directory called mksdcard.
just give it the size of the SdCard you want to create ( in kilobytes or megabytes ) , the name of the resulting file, and you're done :
Open a command prompt, go to your SDK/tool directory, and type :
mksdcard 64M MyNewSdCard
and that's it !


2) Using the emulated SDCard with the emulator

To use the emulated SDCard in the emulator, simply launch the emulator with the '-sdcardEmulatedCard_File_Path' parameter :

So, from the command prompt in the SDK/Tool directory, type :
emulator -sdcard MyNewSdCard

3) Using the emulated SDCard with the emulator from Eclipse :

From eclipse, open the menu entry :
Run / RunConfigurations...

Then on the right panel, choose 'target'
And in the Additionnal Emulator Command Line Options, add
'-sdcard fullPath_to_your_SdCard_File'


And that'all !

4) How to explore the emulated SdCard content and push / pull files from your computer :

Within Eclipse :

Open the DDMS perspective :
Window / Open Perspective / Other... / DDMS

Now select the file explorer tab ( in the right panel ), and you have acces to a classic explorer of your emulated phone, including the sdcard !

Now to push a file from your computer, or pull a file from the emulated device, you have two discrete icons in the upper right corner :

Just use them to to browse and select on your computer the file to pull or push !

Without Eclipse :

Just launch DDMS from the command prompt in the SDK / tools directory.
The file explorer is in the device menu...

3 comments:

  1. Hi
    Thanks for such a useful article.
    I am using windows 7 OS. When I am trying to push images on sdcard it give me error "Files have only read permission". I can see that SDCARD have only read permission. How could I change it to read/write permission.
    Thanks in Advance.

    Regards,

    ReplyDelete
  2. Your blog reviews is really good.This is one of the well organised post.try to get more this kind of information.

    ReplyDelete
  3. How can i run application from sdcard?

    ReplyDelete