Emulating a SD-Card

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Emulating a SD-Card

Postby plusminus » Wed Dec 12, 2007 6:36 pm

Emulating a SD-Card


What you will learn: You will learn how to create an SDCard Image for your emulator.

:?: Problems/Questions: Write it right below...

Difficulty: 1.5 of 5 :)

Part I: Creating an SDCard Image:

[flash width=686 height=475]http://www.anddev.org/images/tut/basic/create_sd_card/screencast.swf[/flash]

The parameters of the command:
mksdcard [-l label] <size>[K|M] <file>

explained:
  • "-l <label>":
    A volume label for the disk image to create.
  • "<size>"
    An integer that specifies the size (in bytes) of disk image to create. You can also specify size in kilobytes or megabytes, by appending a "K" or "M" to <size>. For example, 1048576K, 1024M.
  • "<file>"
    The path/filename of the disk image to create.


Part II:
Once you have created the sdcard image file, you can load it in the emulator at startup using the emulator's -sdcard option.

Code: Select all
// Format:
-sdcard <file>

// Example
-sdcard C:UsersplusminusAppDataLocalAndroidsdcard.img

In Eclipse you have to change the :run: Run-Configuration like in the following picture:

Image


Having done that, we can see the SDCard even with our Android-File-Browser:
Image


Finally pushing files to the SD-Card using the adb.exe on the commandLine:
adb push <source path> /sdcard/<filename>


Regards,
plusminus
Last edited by plusminus on Mon Dec 17, 2007 4:24 pm, edited 1 time in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby Katharnavas » Thu Dec 13, 2007 5:07 am

Hi,
That part is ok. How about pushing files to the SDCard the problem starts there for me. Any suggestions regarding this will be useful.
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

Postby living_sword » Thu Dec 13, 2007 7:46 am

Katharnavas wrote:Hi,
That part is ok. How about pushing files to the SDCard the problem starts there for me. Any suggestions regarding this will be useful.



adb push <source path> /sdcard/<filename>
Image
living_sword
Junior Developer
Junior Developer
 
Posts: 23
Joined: Fri Nov 23, 2007 4:44 am

Postby plusminus » Mon Dec 17, 2007 4:25 pm

Hello living_sword,

thx for mentioning it :!: added it above.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby raquibulbari » Sun Jan 27, 2008 9:01 am

thanks +-
great tutorial with flash :)
Shimugool
User avatar
raquibulbari
Developer
Developer
 
Posts: 25
Joined: Sun Dec 16, 2007 6:31 am
Location: dhaka,bangladesh

Postby puyopuy » Sun Feb 03, 2008 4:55 am

Hi everyone,

I tried to following the steps to add sdcard into emulator but got an error "Emulator quit with an error!". If I remove that options, the emulator running fine but cannot see the sdcard. Any idea how to fix this problem?

Thanks in advance
puyopuy
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sun Feb 03, 2008 4:46 am

Top

Postby plusminus » Sun Feb 03, 2008 10:54 am

Hello puyopuy,

perhaps you have a blank/space in your path :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby puyopuy » Mon Feb 04, 2008 6:50 am

Hello plusminus,

Thank you for you quickly response. I'm using "-sdcard c:temp2sdcard.img" in the command line options and I cannot see any blank/space in my path. I attached the img this time, could you please test it in your environment?

I used the following command to create the image file.

mksdcard 512K c:temp2sdcard.img

Thanks
puyopuy
puyopuy
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sun Feb 03, 2008 4:46 am

Postby plusminus » Mon Feb 04, 2008 9:49 am

Hello puyopuy,

our creation only differs in one thing you are using no label (according to the mksdcard call-syntax it is optional...)

I created and attached a 128MB sdcard-image (zipped to 128kB :lol:) for you having used the following command:
Code: Select all
F:Programming...tools>mksdcard -l mySDCard 128M C:UsersplusminusDesktopsdcard.img

(I used the latest SDK "m3-rc37a")

Perhaps it works with this image. :?

Regards,
plusminus[b]
Attachments
sdcard.zip
Fresh 128 MB SDCard Image for Emulator created with &quot;m3-rc37a&quot; mksdcard-SDKtool. Zipped to 130kB!
(127.46 KiB) Downloaded 1252 times
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby puyopuy » Tue Feb 05, 2008 3:22 am

Hi plusminus,

Your image file working for me now. I don’t know what is wrong with my environment, I create the image file again today without the label it’s working now.

Thanks alot
puyopuy
puyopuy
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sun Feb 03, 2008 4:46 am

Postby venkat » Fri Feb 29, 2008 1:24 pm

Hi PlusMinus,
I have created sdcard and push images into sdcard. i can see images using DDMS tool . when i restart eclips all the images will be gone. i have to push images again and than i am testing my application.
Can you tell me what is the problem?

Thansk :)
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Postby plusminus » Fri Feb 29, 2008 5:02 pm

Hello venkat,

maybe you accidentially left a "-wipe-data" :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby venkat » Fri Feb 29, 2008 5:13 pm

What i suppose to do now? :(
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

what to do

Postby cadlg » Fri Feb 29, 2008 5:50 pm

Remove the -wipe-data from the command line options in the run dialog, push your images again if needed, and run your app.

Good luck !
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Postby venkat » Mon Mar 03, 2008 9:28 am

can you ne1 tell me , how to remove "-wipe-data" :)
Thanks ,
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Top
Next

Return to Novice Tutorials

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests