How to emulate and use SD card for the Android Emulator

android emulator

How to emulate an SD card for the Emulator

Android application development involves saving files (images, songs etc.) to the emulator and accesses them at runtime. These files should be saved to an SD card on the emulator that can be accessed using “/sdcard”. To enable the SD card, first you need to create an SD card image. In order to create an SD card image, Google provides a tool in their SDK/tools directory – “mksdcard”.

While running “Mksdcard” the following parameters are necessary:

a) Size of the SD card you want to create (in Kilobytes or Megabytes)
b) Full path (Including name of the image file) of the resulting image file

Example:

Open a command prompt; go to your SDK/tool directory, and type

Mksdcard -l mySdCard 128M D:\somefolder\sdcard.img

 

How to use or access Android emulated SDCard in Android Emulator

To use the emulated SDCard in the emulator, simply launch the emulator with the
-sdcard EmulatedCard_File_Path‘ parameter:

 

How to use or access Android emulated SDCard from command prompt

To use or access Android emulated SDCard from command prompt, Open command prompt; go to your SDK/tool directory, and type

-sdcard D:\somefolder\sdcard.img

 

How to use or access Android emulated SDCard from Eclipse

To access emulated SDCard with the emulator from Eclipse, follow these steps

  1. From eclipse, open the Run-Configuration.
  2. Then on the right panel, choose ‘target’
  3. And in the Additional Emulator Command Line Options, add 
-sdcard <fullPath_to_your_SdCard_File>

Example: -sdcard D:\somefolder\sdcard.img

 

How to add files to emulated SDCard from command prompt

To add files (eg: .jpg file) to emulated SDCard from command prompt, follow these steps

  1. Open command prompt
  2. Go to your SDK/tool directory, and type
    adb push /sdcard/ command
    
    Example: adb push “D:\icon.jpg”/ sdcard

 

You Might Also Like

3 comments on “How to emulate and use SD card for the Android Emulator

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 2 = ten

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge