Android Tutorial: Creating and Using an SD Card in the Emulator

In a previous post, I mentioned how user-friendly Android is for developers. There’s extensive documentation and information on the architecture, the different components and best practices. However, the documentation has a few blind spots. Many of the tools have little documentation and no usage examples. The information is there, it’s just hidden behind a few layers of Android theory.

So I’m going to try and document a few of the basic things that you’ll probably need to know to start developing Android applications. Only for beginners and intermediate Android developers.

The first issue I ran into was trying to load files into the Android emulator. For instance, if you want to load MP3 files on a “real” Android phone, you’ll probably insert an SD card into the phone. The emulator can emulate this, but you need to jump through a few hoops:


First, you will need to create an SD card image file. This is comparable to, for instance, an ISO image of a CD-ROM. Creating an image is done via the mksdcard tool. For instance:

mksdcard -l mysdcard 128M sdcard.img


If you want to access the image, the emulator must be running with the image loaded. I’m going to assume you’re using the Eclipse tools. In there you need to specify the image on the command line. Open the “Run configurations…” dialogue and configure the image as follows (don’t forget to put in the correct directory)



Next start the emulator and verify that the SD card is loaded. The best way to do this is in the DDMS tool. To access it: click on the open perspective button:


If the DDMS isn’t in the list, click “Other…” and choose it from there. Open the file explorer and you should be able to open the sdcard:



Add files to the sdcard: There are two options: either you can use the two icons in the top right corner of the DDMS tools (android_pull_push) or you can use the command line tools. The following command pushes the file to your sdcard:

adb push myfile.mp3 /sdcard/

Not that the location on the Android phone (the “/sdcard/” part) needs to have “unix-style” forward slashes, so keep that in mind if you’re running on Windows.


And that’s it. the file should appear in the DDMS file explorer. Next time, we’ll try to actually do something with the file we places on the Android emulator.

Image credit

  • Hey nice tutorial but i have some problem :-
    I have made the sdcard
    But i can not use the buttons on the DDMS File explorer they are turned grey and i can not click on them
    Plus i want to ask is this the only way to add videos to my project??
    I want some videos embedded in my project which will play on specific activities

  • Anselmo

    hey man, nice tutorial, thank you!

  • Hari

    Hi Peter,
    Very nice tutorial. Could you please point me the follow post to this one where you show us how to access and manipulate the files from CD CARD?

  • Chuasiarocker

    Is this the only way to add images into the sdcard? Is there like a coded kind to add in images?

  • It depends, if the video is part of your project, you can probably at it as some kind of resource. Or, maybe even better, you can load it from an url when you need it.
    If, on the other hand, you want the play video that is added by the user, I think the SD card will be your best bet.

  • Hello Hari,
    I haven't been able to continue the project. I'd first like to get my very own Android phone, but I keep postponing the purchase, waiting for the perfect phone 🙂
    In any case, I think the Android docs will be able to help you out. Take a look at… This has most of the information you'll need.

  • I think the same resource I pointed Hari to will help you too:
    You can put stuff on the SD card from your Android application.
    If you want to create reference data from some external program, you can use the adb tool, which is documented right here:

  • Thank you for the kind comment. I plan to create more Android tutorials in the future. It's just that a few other projects have currently taken over my spare time.
    But keep checking back, there will be more mobile stuff.

  • Abhi

    “Failed to push 0007.jpg on emulator-5554: Read-only file system”

    This is what I get on adding the image file..I want to know how to change the permission to read and write..thx

  • Ps6717

    I am a new Android developer. Excellent tutorial. I was able to push images to the sdcard after reading this.

  • Thank you for the kind words. I hope to bring some more Android tutorials in the future.

  • Hey Abhi, I’m not sure if I will be of much help. One thing I can think of is to make sure you are writing to the sdcard. Some other parts of the filesystem might be readonly.

  • Nice tutorial. Could have been better.

  • Narayanan

    Sir I want push a xml file which is in Tomcat Server to sdcard Emulator device to retrieve and parse the xml file.Pls help me to fix this issue

  • This is definitely not possible using the tutorial I presented here. I think you’ll find what you need to get started on the Data Storage pages of Android (
    Good luck!

  • SD

    Hi I am also getting an error while upload a small jpg file.
    Failed to push selection: Read-only file system
    I noticed in the File Explorer the sdcard is having permissions as d——
    no permissions to update the sdcard folder. Kindly advise.

  • Ananya Sundar

    good tutorial for SD card start up.

  • Anandnair07

    “Failed to push 0007.jpg on emulator-5554: Read-only file system”

  • This tutorial is fairly old by now and I’m not sure if I’ll be able to update it in the near future.
    You might want to check if you’re using the correct folder (make sure it’s the SD card) and if there is some kind of recently added options to switch the read-only mode on SD cards.

  • Vicki

    I tried this tutorial, and got read only errors too. I found an easier way is to edit your AVD to have an SD card (in AVD manager, edit your AVD and specify a size for the SD card). Kill and relaunch the emulator, and the DDMS view will now let you push files properly. Also, if you use this approach, don’t use the -sdcard command line option anymore.

  • NM

    I did exactly as the tutorial says and yet I can’t see the sdcard in DDMS … I’ve the latest android sdk-version-10 and i spent a day trying to insert the sdcard to the emulator. Any help?

  • Did you add the command line option? (step 2)
    Are you sure the path is correct? What is the working directory of the emulator executed?
    Are you seeing any error messages on startup?
    I think answering those questions should help you get a little further.
    Good luck!

  • Hyunjungsoh

    How come I can’t see the images I pushed inside the gallery?