添加非Android xml文件的Andr​​oid项目 [英] Adding non-android xml file to android project

查看:84
本文介绍了添加非Android xml文件的Andr​​oid项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有添加非Android的xml文件导入init.xml在Eclipse中的Andr​​oid项目的问题。这个文件是用来初始化一些仿真过程中,这是不符合Android的连接。 Eclipse不承认它,如果简单地把它纳入项目目录,并喜欢写东西。

I have problems with adding a non-android xml file init.xml to android project in Eclipse. This file is used to initialize some simulation process, which is not connected with android. Eclipse doesn't recognize it if simply put it into project directory and write something like

File file = new File("init.xml");

我应该声明在一些特定的方式文件,或把它放到其他目录?

Should I declare the file in some specific way or put it into other directory?

推荐答案

您可以把资产文件夹内的文件,然后你可以使用<一个访问该文件HREF =htt​​p://developer.android.com/reference/android/content/res/AssetManager.html相对=nofollow> AssetManager 和的 getAssets()

You can put this file inside the assets folder and then you can access this file by using AssetManager and getAssets().

AssetManager assetManager = getAssets();
InputStream instream = assetManager.open("init.xml");

这篇关于添加非Android xml文件的Andr​​oid项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆