如何在android中的模拟器上将文件导入sdcard?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2506661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to import files into the sdcard on emulator in android?
提问by Praveen
i want to load some photos into my sd card image in the emulator. how to do this by command prompt.how to do that?
我想在模拟器中将一些照片加载到我的 SD 卡图像中。如何通过命令提示符执行此操作。如何执行此操作?
回答by Steve Haley
I've found it to be incredibly clumsy and not work very well, but the command to use is: adb push yourfile.xxx /sdcard/yourfile.xxx
. For this to work you've got to have the file in the same directory as adb.exe, which is in the tools folder of your SDK directory, or have set up adb as a system-wide recognisable command. (I don't remember how to do that, but I know it can be done). This also assumes you've set up an SD card through the AVD manager. However, the problem I faced when doing this is that sometimes the file would appear on the emulator with a size of 0 bytes. What I mean is that I could see the file in the DDMS file browser in Eclipse, but after doing the necessary emulator restart, the files would then be shown with the 0 byte size. I couldn't find a pattern on why that happened, but trying a few times in a row eventually worked.
我发现它非常笨拙并且不能很好地工作,但是要使用的命令是:adb push yourfile.xxx /sdcard/yourfile.xxx
. 为此,您必须将该文件放在与 adb.exe 相同的目录中,该目录位于 SDK 目录的工具文件夹中,或者已将 adb 设置为系统范围内可识别的命令。(我不记得怎么做,但我知道可以做到)。这还假设您已经通过 AVD 管理器设置了 SD 卡。但是,我在执行此操作时遇到的问题是,有时文件会以 0 字节的大小出现在模拟器上。我的意思是我可以在 Eclipse 的 DDMS 文件浏览器中看到该文件,但是在执行必要的模拟器重新启动后,文件将以 0 字节大小显示。我找不到为什么会发生这种情况的模式,但连续尝试几次最终奏效。
回答by Rishi Pandey
On Android Studio
在 Android Studio 上
- Run Emulator
- open android device monitor
- scroll down and select sdcard
- Click on Push file into sdcard icon at top right
- choose the file Hope this helps..
- 运行模拟器
- 打开安卓设备监视器
- 向下滚动并选择 SD 卡
- 单击右上角的将文件推送到 sdcard 图标
- 选择文件希望这有帮助..
回答by npittaya
I've just found out how to add some files in the SD card image.
我刚刚发现了如何在 SD 卡映像中添加一些文件。
- Turn all running emulators off but keep Eclipse on.
- Using thecommand line, start the ddms tool. ddms
- Now start stand-alone emulator console. emulator -avd myAVDname -sdcard mysdcard.img
- Push a file into the sdcard. adb push yourfilename /sdcard/
- You should get a message (how much memory it occupies)
- In Eclipse, you will see the folders (including SD card and the files you just add) appear.
- 关闭所有正在运行的模拟器,但保持 Eclipse 开启。
- 使用命令行启动 ddms 工具。数据管理系统
- 现在启动独立模拟器控制台。 模拟器 -avd myAVDname -sdcard mysdcard.img
- 将文件推入 SD 卡。adb push yourfilename /sdcard/
- 你应该得到一条消息(它占用了多少内存)
- 在 Eclipse 中,您将看到文件夹(包括 SD 卡和您刚刚添加的文件)出现。
For me, the files didn't appear at the first time in File Explorer, then I closed the emulator and turned it on again. Now it works!
对我来说,文件第一次没有出现在文件资源管理器中,然后我关闭了模拟器并再次打开它。现在它起作用了!
回答by curiousEngine
in Eclipse, Open the DDMS Perspective.
在 Eclipse 中,打开 DDMS 透视图。
Start an Emulator. Select it in the Devices.
启动模拟器。在设备中选择它。
Click on the File Explorer Tab in DDMS.
单击 DDMS 中的文件资源管理器选项卡。
THEN THE FOLLOWING DOCUMENTATION FROM OFFICIAL ANDROID WEBSTIE: http://developer.android.com/tools/debugging/ddms.html
然后来自官方 ANDROID WEBSTIE 的以下文档:http: //developer.android.com/tools/debugging/ddms.html
Working with an emulator or device's file system
使用模拟器或设备的文件系统
DDMS provides a File Explorer tab that allows you to view, copy, and delete files on the device. This feature is useful in examining files that are created by your application or if you want to transfer files to and from the device.
DDMS 提供了一个文件资源管理器选项卡,允许您查看、复制和删除设备上的文件。此功能在检查由您的应用程序创建的文件时或如果您想将文件传输到设备或从设备传输文件时非常有用。
To work with an emulator or device's file system:
要使用模拟器或设备的文件系统:
In the Devices tab, select the emulator that you want to view the file system for. To copy a file from the device, locate the file in the File Explorer and click the Pull file button. To copy a file to the device, click the Push file button on the File Explorer tab.
在“设备”选项卡中,选择要查看其文件系统的模拟器。要从设备复制文件,请在文件资源管理器中找到该文件,然后单击拉取文件按钮。要将文件复制到设备,请单击文件资源管理器选项卡上的推送文件按钮。
回答by Mathayo
Answer here also. You need not open cmd when using eclipse.
也在这里回答。使用eclipse时不需要打开cmd。
Problems trying to push files into android device using eclipse
回答by shyam vora
first,download magiciso(http://www.magiciso.com/Setup_MagicISO.exe)
首先,下载magiciso( http://www.magiciso.com/Setup_MagicISO.exe)
after downloading When your emulator is not open go to your avd files(c:/document and settings/"user name"/.android)
下载后当您的模拟器未打开时,转到您的 avd 文件(c:/文档和设置/“用户名”/.android)
there is your avd named folder
有你的 avd 命名文件夹
then open sdcard.img with magiciso
然后用magiciso打开sdcard.img
now you have to drag and drop files in your magic iso window
现在你必须在你的魔法 iso 窗口中拖放文件
don't forget to save the file
不要忘记保存文件