android查询大文件,加载和查询大型xml文件Android

在开发Android应用时,遇到10MB左右的XML数据源导致内存问题。目前通过XPath加载到ListView中,但随着文件增大,可能引发性能瓶颈。寻求最佳方式在不消耗大量内存或增加处理时间的情况下,有效地加载和查询XML文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I’m building an android app and I have a xml file which is my data source, I load it to make queries using XPath and then load the results in a ListView. The problem comes out when the xml file start to become bigger(up to 10MB). It means that i could have problems with memory, i guess. I would like to know what’s the best way to load the xml and make searchs into the file without compromise the device’s memory or waste valuable time processing data.

Here is when i load the xml file:

InputStream isRaw = context.getResources().openRawResource(R.raw.xmlbooksource);

_xmlBookSource = new InputSource(isRaw);

And here i make a query using XPath:

nodeResultSet = (NodeList) xpath.evaluate(xpathExpression, _xmlBookSource, XPathConstants.NODESET);

all advices are welcome.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值