Android SD card usage instructions

Source: Internet
Author: User

I recently made a music player and needed to add MP3 files to the SD card. The following describes how to use sdcard.

The android simulator allows us to use the disk image in FAT32 format as the SD card simulation:

All of the following operations are performed in Windows

1. Create an image file

Run cmd to enter the tools directory of the android SDK and run mksdcard to create the SDK.

For example, my tools directory is:

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>  

Then:

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>mksdcard 128M sdcard.img  

The first parameter is the size of the sdcard to be created (determined by the size), and the second parameter is the name of the sdcard.

2. Start the android simulator with sdcard

On the DOS interface,

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>emulator -sdcard sdcard.img  

In this way, a folder named sdcard. IMG. Lock is generated dynamically under the tools directory, and disappears when the simulator is disabled.

Note: Do not close this DOS window. Otherwise, the simulator will be closed and the subsequent step cannot be executed.

3. Add a file to sdcard

In addition, to open a DOS window (CMD), you still need to CD it to the tools directory of the android SDK, and use the ADB push command to add

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>adb push new.JPG /sdcard  

The first parameter is the full name of the image (mp3) to be added. If there is a space in the name, enclose it with double quotation marks.

For example:

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>adb push "First Start.mp3" /sdcard  

The second parameter is the newly created sdcard.

4. view the added file

In this step, you may need to restart the android simulator with sdcard to view the resource file you just added. That is, you must first turn off the simulator.

Then

  
  
  1. E:\skyland\android-sdk-windows-1.0_r2\tools>emulator -sdcard sdcard.img  

 

Use sdcard in eclipse

If the. imgfile is not created, go back to the beginning and do step 2.

Note: If you do not start the simulator in step 1 but do the following, an error is reported indicating that the SDK card is a read-only file and cannot be added.

1. Start eclipse and choose Window> perspective> Other> ddms.

Select the sdcard and click push to add the image resources to the sdcard.

2. Use sdcard resources to compile Android scripts

If you need to use sdcard resources when compiling Android applications

Right-click

  
  
  1. Run As-->Open Run Dialog-->Target  

Add the startup parameter to the aditional emulator command line options of the target tag.

  
  
  1. -sdcard E:\skyland\android-sdk-windows-1.0_r2\tools\sdcard  

Use the file Explorer File Browser in the ddms label to transfer

Note that when importing data to the sdcard of the simulator, the error "failed to push Selection: invalid argument" is often reported because of poor Chinese support, you only need to remove the Chinese characters of the file name to be imported and change them to English letters. In addition, there should be no spaces in the name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.