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 是單純的整數,其所指定的大小是以位元組為單位。你也可以
以 KB、MB 或 GB 為單位來指定大小
至 size。例如 1048576K 或 1024M 。
大小下限為 9 M。Android Emulator 無法使用更小的圖片。大小上限為
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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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)."]]