How to load and use the SDCard card in the OPhone Simulator

Source: Internet
Author: User

The sdcardfile is generated using the mksdcard.exe command in the toolsdirectory. to generate an sdcard file of MB, run the following command:

 
 
  1. mksdcard -l mycard 256M card/mycard.img 

Note the following six points when using the mksdcard command in the OPhone simulator:

1. The mycard command can use three sizes: byte, K, and M. If only a number is used, bytes are used. It can be followed by K, for example, 262144 K, or 256 M.

2. The Virtual File Created by mycard is at least 8 Mb. That is to say, the simulator only supports Virtual files larger than 8 Mb.

3. The-l command line parameter indicates the volume label of the virtual disk. This parameter does not exist.

4. The extension of a virtual file can be arbitrary, such as mycard. abc.

5. The mksdcard command does not automatically create a non-existing Directory. Therefore, before executing the command above, you must create a card directory in the current directory.

6. The mksdcard command is an sdcard virtual file generated based on the actual size. That is to say, the size of the virtual file generated for 256 MB is mb. If a large virtual file is generated, check whether your hard disk space is sufficient!

After executing the preceding command, run the following command to start the OPhone simulator:

 
 
  1. emulator -avd avd1 -sdcard card\mycard.img 

In the development environmentEclipse), You can set the startup parameters in the Run Configuration dialog box, as shown in 1.

You can also set the default startup parameters in the Preferences dialog box. 2. In this way, the command line parameters for loading the sdcard virtual file are automatically added to the newly created Android project.

If you use the OPhone simulator, the method is the same. Then, in the Setting field of the VM, check whether the sdcard is found, as shown in figure 2.

Figure 3

So how can I view the content in the sdcard virtual device? There are many methods. The simplest is to use the DDMS perspective with the android eclipse plug-in. 4.

 

The buttons in the upper-right corner can be used to delete or add files.

If you do not use the DDMS plug-in or do not work in eclipse, you can also use other tools to operate sdcard Virtual Devices. For exampleWindowsYou can use mtoolsSoftwareThe http://files.cnblogs.com/nokiaguy/winima81.rar can be downloaded from the address below:

InstallAfter that, use mtools to open mycard. img and you will see the corresponding directories and files. 5.

If you are usingLinuxYou can use the mount command to map an sdcard virtual file to a linux directory. Run the following command first:

 
 
  1. mount -o loop mycard.img /mnt/card 

After the preceding command is executed, the following error is returned:

 
 
  1. mount::you must specify the filesystem type 

The cause of the above error is that the imgfile contains mbr at the beginning, so that the mount command cannot be identified. Of course, skip this step. We can execute the following command to check how many bytes should be skipped:

 
 
  1. fdisk -ul mycard.img 

The output content is shown in Figure 6.

 

Find a start value. In this example, It is 129, and then find the Units value, which is 512.

512*129 = 66048Ok, use the following command:

 
 
  1. mount -o loop,offset=66048 mycard.img /mnt/card 

After executing the preceding command, go to the/mnt/card directory and you will see the files in mycard. img.

If you want to access the files in the sdcard In the android virtual machine, you must first obtain the path of the sdcard.CodeAs follows:

 
 
  1. java.io.File sdcardDir = android.os.Environment.getExternalStorageDirectory(); 
The sdcard directory is generally "/sdcard ".

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.