充气从内部存储器XML文件 [英] Inflate XML file from internal memory

查看:110
本文介绍了充气从内部存储器XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经复制从 /资产的XML文件来我的应用程序数据文件夹(数据/数据​​/ package.name /文件/ )。我这样做,因为用户将能够修改大量的数据,我想这些数据保存在内存中,然后再加载它,当他们重新启动应用程序。这一切运作良好,使用根浏览器,我可以看到XML文件被正确拷贝到数据目录。

I've copied an XML file from /assets to my applications data folder (data/data/package.name/files/). I'm doing this because the user will be able to modify a lot of data, and I want to save that data to the internal memory and then load it again when they restart the app. This all works well, using Root Browser I can see the XML file is properly copied to the data directory.

现在我需要充气使用 LayoutInflater 这个XML文件。我将如何访问此文件?随着 XmlResourceParser XmlPullParser

Now I need to inflate this XML file using a LayoutInflater. How would I access this file? With an XmlResourceParser or XmlPullParser?

推荐答案

您不能使用夸大该文件 LayoutInflater 。首先,你只能抬高布局的资源的,不是任意的文件。其次,基于在第一个段的描述,这不是在首位的布局文件中。

You cannot inflate that file using LayoutInflater. First, you can only inflate layout resources, not arbitrary files. Second, based on the description in your first paragraph, it is not a layout file in the first place.

如果要分析任意XML,使用DOM,SAX或 XmlPullParser

If you want to parse arbitrary XML, use the DOM, SAX, or XmlPullParser.

这篇关于充气从内部存储器XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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