by Mårten Österberg - Android, Embedded
Working with external storage in the Android emulator could be a little tricky and the documentation is not easy to find. I’ll try to give a brief walk through of the steps needed to create a SD card image, mount the image in Linux, put content on it and use it in the emulator.
Creating a SD card image
In both the 1.1 and 1.5 version of the SDK there is a tool called mksdcard located in the SDK Install Dir/tools folder. Simply run
|
1 |
./mksdcard 128M my128MbCard |
to create a 128Mb SD card with the name my128MbCard.
Mounting a SD card image in Linux
To be able to put content on to the card you can mount the card in Linux. It will then simply appear as a folder in the filesystem.
First make a directory in the /media folder:
|
1 |
sudo mkdir /media/mycard |
Then mount the card as a loopback device:
|
1 |
sudo mount -o loop my128MbCard /media/mycard |
Adding content to the card
With content we usually mean media content like images and videos. Images and videos are located in a folder called /dcim/Camera. You could of course add any content to the card. When you are done copying your files be sure to umount the card otherwise it will not be usable from the emulator.
|
1 |
sudo umount /media/mycard/ |
Using the card in the emulator
Google added something called Android Virtual Device (AVD) to the SDK 1.5. To create a new AVD using our newly created SDcard image run the following:
|
1 |
./android create avd --name myAVD --target 2 --sdcard my128MbCard |
Target 2 means that we want to use the 1.5 API features in the device. Now we simply fire up the emulator and start using our content:
|
1 |
./emulator -avd myAVD |
More information about the new SDK can be found here: SDK
At this time I am ready to do my breakfast, later than having my breakfast coming over again to read further news.
I was recommended this web site by my cousin. I’m now not certain whether or not this publish is written by way of him as no one else realize such designated about my difficulty. You’re wonderful! Thanks!
I didn’t get what I want. so poor service.
… [Trackback]…
[...] Read More: jayway.com/2009/04/22/working-with-sd-cards-in-the-android-emulator/ [...]…
Thanks Buddy ! It is working. By the way what is the idea behind mount and unmount ? If anyways we are going to unmount then why mount ?
Here is the link used for me:
http://androiddevelopement.blogspot.com/2011/09/how-to-emulate-sd-card-with-android.html
Hi
If you are using Eclipse it is very easy to create SD card at the time of creating a new virtual device.
Thanks !!!
I will try it and i wil tell you about the results.
In OSX, just name the image .iso and type ‘open mycard.iso’ and it will be mounted and available in Finder
[...] http://www.jayway.com/2009/04/22/working-with-sd-cards-in-the-android-emulator/ [...]
while creating itself select sd card .its simple.then using file explorer from window->view you can store and retrive data on sdcard!!!!
Hi
Do you know how to make a sdcard with partition in the sdcard?
Thanks
Helpful explanation. I made a Bash script for testing my Android app that does the things above: https://github.com/vermasque/song-alarm/blob/master/tests/make_sdcard.sh
can you explain for windows
Crisp Info!
I am using Android SDK by Eclipse on windows 7 environment. How can i create folder in somelocation of SD card?
[...] can use the DDMS perspective on Eclipse (www.jayway.com/2009/04/22/working-with-sd-cards-in-the-android-emulator/) to view the sd card on the running emulator, and can copy files to the root folder, but I [...]
Thanks a lot for sharing.
But i want to make one small application which will check status of my External storage,Add files or pictures into External storge ,and read that data from Gallery folder of my emulator.
Can u help me to accomplish my app.
Thanks
very useful paper.. Thank you..
A question…
The sdcard format is FAT. Is possible to change this format to ext2 or ext3 format ?
Thanks in advance!!
hi
this is very useful and working well.thank you
thanks. that was helpful
@ #5 Andy, I understand you are using a Mac like myself. See this:
http://2cupsoftech.wordpress.com/2010/05/19/working-with-android-sd-cards-image-on-mac/
[...] an sd card and connect that sd card image with the an android emulator. The post by Jayway team (http://www.jayway.com/2009/04/22/working-with-sd-cards-in-the-android-emulator/) helped me to get started but those instructions are linux specific and didn’t work for me on [...]
Great way to transfer files in an emulator!! I’m using Android 2.1, waiting for the Google I/O conference news! This is wonderful!
[...] http://www.jayway.com/2009/04/22/working-with-sd-cards-in-the-android-emulator/ http://wiki.frandroid.com/wiki/DevGuide/tutorials/hello-world.html http://www.android.encke.net/ [...]
Thanks a lot man….it helped me to access the sdcard in linux……i am using the 2.1 version of the SDK……though the last two steps for emulator are not needed if you are using eclipse for developing apps…..in eclipse go to
Run->Debug Configurations->Target->Addtional Emulator command line options, type the following
-sdcard /the path where we have created the my128MbCard/my128MbCard
once again thanks a lot
Hay, Thanks buddy steps are working as it is…
Hey,
For the last steps of creating AVD, Can we use the -sdcard option for the emulator?
./emulator -sdcard my128MbCard .
Regards,
Channa
I figured this out on Windows, in case anyone needs that info. Go to http://www.androidref.com and look for How to create an SD card, store a contact photo, and display the photo on the handset..
Thanks budy!
Hi. It was an useful article. Thanks
When I try to mount, it says
mount: -o loop: option not supported
what should i do
What do you do if you don’t have linux?
Hi Elad,
I don’t have much experience with the Android SDK on windows but I suppose you could still mount the iso file using a mount tool. This might be a good start: http://www.howtogeek.com/howto/windows-vista/mount-an-iso-image-in-windows-vista/
[...] 14, 2009 First of all, you may wish to have a look here, and setup a memory card in your project directory called my128MbCard if you want to use any of the [...]
Thanks for this tutorial!! :) It was very helpful.