最新消息:20210917 已从crifan.com换到crifan.org

【已解决】如何向Android模拟器AVD中添加导入文件

Android crifan 5517浏览 0评论

【问题】

可以用ADT去调试android程序了。

想要添加进来一个文件,用于代码去测试。

【解决过程】

1.后来经过折腾,发现,在调试的时候,可以看到DDMS:

can see ddms file explorer

中有个File Explorer,即文件浏览器。

然后其右上角有个按钮:“Push a file onto the device”

push a file onto the device

点击后弹出文件选择对话框:

choose the file then ok to import

然后导入后,即可看到对应的文件。

是存放在

/mnt/sdcard/

路径下的:

imported file see in file explorer

即,知道了文件的路径为:

/mnt/sdcard/DDDemoFile_onlyDevInfo.ddl

然后,就可以写代码,去操作了。

比如:

		//String file = "/mnt/sdcard/DDDemoFile.ddl";
		String file = "/mnt/sdcard/DDDemoFile_onlyDevInfo.ddl";
		CharStream cs = null;
		try {
			cs = new ANTLRFileStream(file);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

 

【总结】

ADT->DDMS->File Explorer->“Push a file onto the device”->选择文件并导入

然后就可以在:

/mnt/sdcard/

中找到你刚导入的文件。

之后,写java代码,操作该文件,该文件对应的路径也就是:

/mnt/sdcard/xxx.xxx

转载请注明:在路上 » 【已解决】如何向Android模拟器AVD中添加导入文件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
93 queries in 0.187 seconds, using 23.43MB memory