mksdcard
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以使用 mksdcard
工具创建 FAT32 磁盘映像,然后将该映像加载到运行不同 Android 虚拟设备 (AVD) 的模拟器中,以模拟多个设备中存在相同 SD 卡的情形。
Android SDK 工具软件包中提供的 mksdcard
工具位于 android-sdk/emulator/mksdcard
内。
如果您不需要可在多个虚拟设备之间共享的磁盘映像,则无需使用 mksdcard
命令。默认情况下,模拟器会使用由活动 AVD 生成并存储的默认映像。
用法
如需使用 mksdcard
工具,请使用以下命令:
mksdcard -l label size file
选项
下表介绍了 mksdcard
的命令行选项:
选项 |
说明 |
-l label |
指定要创建的磁盘映像的卷标 |
size |
一个整数,用于指定要创建的磁盘映像的大小。
如果 size 是一个简单整数,则表示以字节为单位来指定大小。您还可以使用千字节、兆字节或千兆字节来指定大小,只需分别为 size 附加 K、M 或 G 即可。例如,1048576K 或 1024M 。大小下限为 9M。Android 模拟器无法使用比这更小的映像。大小上限为 1099511627264 字节,相当于 1023 GB。
|
file |
指定要创建的磁盘映像的路径/文件名(相对于当前工作目录)。
|
示例
创建 mySdCardFile.img
磁盘映像:
mksdcard -l mySdCard 1024M mySdCardFile.img
启动两个运行不同 AVD 的模拟器。使用 -sdcard
标志指定您创建的磁盘映像的名称和路径:
emulator -avd Pixel_API_25 -sdcard mySdCardFile.img
emulator -avd NEXUS_6_API_25 -sdcard mySdCardFile.img
如需详细了解
emulator
命令及其选项,
请参阅
从命令行启动模拟器。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# mksdcard\n\nUse the `mksdcard` tool to create a FAT32 disk image that you can load into\nemulators running different Android Virtual Devices (AVDs) to simulate the presence\nof the same SD card in multiple devices.\n\n\nThe `mksdcard` tool provided in the Android SDK Tools package\nis located in \u003cvar translate=\"no\"\u003eandroid-sdk\u003c/var\u003e`/emulator/`\u003cvar translate=\"no\"\u003emksdcard\u003c/var\u003e.\n\n\nIf you don't need a disk image that can be shared\namong multiple virtual devices, you don't need to use the `mksdcard` command.\nBy default, the emulator uses the default image that is generated by and stored with the\nactive AVD instead.\n\n### Usage\n\n\nTo use the `mksdcard` tool, use the following command:\n\n```\nmksdcard -l label size file\n```\n\n### Options\n\nThe following table describes the command-line options of `mksdcard`:\n\n| Option | Description |\n|--------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `-l `\u003cvar translate=\"no\"\u003elabel\u003c/var\u003e | A volume label for the disk image to create |\n| \u003cvar translate=\"no\"\u003esize\u003c/var\u003e | An integer that specifies the size of the disk image to create. If \u003cvar translate=\"no\"\u003esize\u003c/var\u003e is a simple integer, it specifies the size in bytes. You can also specify the size in kilobytes, megabytes, or gigabytes by appending K, M, or G to \u003cvar translate=\"no\"\u003esize\u003c/var\u003e. For example, `1048576K` or `1024M`. The minimum size is 9M. The Android emulator cannot use smaller images. The maximum size is 1099511627264 bytes, which equates to 1023 GB. |\n| \u003cvar translate=\"no\"\u003efile\u003c/var\u003e | The path/filename of the disk image to create relative to the current working directory. |\n\n### Example\n\n\nCreate the `mySdCardFile.img` disk image: \n\n```\nmksdcard -l mySdCard 1024M mySdCardFile.img\n```\n\n\nStart two emulators with different AVDs. Use the `-sdcard` flag to specify the name\nand path of the disk image you created: \n\n```\nemulator -avd Pixel_API_25 -sdcard mySdCardFile.img\nemulator -avd NEXUS_6_API_25 -sdcard mySdCardFile.img\n```\nFor more information about the `emulator` command and its options, see [Start the emulator from the command line](/studio/run/emulator-commandline)."]]