有没有办法使用getResources(),以避免大小限制。openRawResource()没有办法、大小、以避免、openRawResource

2023-09-06 06:06:24 作者:春风不识路

我想,当应用程序第一次运行,从RES /原始文件夹在我的Andr​​oid项目加载XML文件。我做这一行:

 的InputStream xmlStream = getResources()openRawResource(R.raw.xmlfile)。 

然后我想使用SAX解析器从XML文件中获取数据。在这样做时LogCat中显示了以下错误:

 数据超过UNCOM preSS_DATA_MAX(1290892 1048576 VS) 

反正是有解决这个1MB限制?

一些谷歌搜索后,我发现谁都有自己的文件分割成块1MB的人,但这些都不是XML文件,所以我不知道我会怎么做的InputSource我的SAX解析器之前将其重新加入。

我的文件不是由我创造,所以我真的不能编辑它(虽然我可能),如果我从网络上获取我的code工作。及其周边的大小1,300KB,所以我想不必下载它每次运行应用程序

解决方案   

反正是有解决这个1MB限制?

给你的文件扩展名,将不会COM $ P $在生成过程中通过 AAPT pssed。举例来说,我觉得它跳过COM pressing .MP3 文件。

微信连上wifi没有问题,用流量就连不上网,流量可以打开网页怎么回事

I am trying to load an XML file from res/raw folder in my Android project when the app first runs. I do this with this line:

InputStream xmlStream = getResources().openRawResource(R.raw.xmlfile);

I then want to use a SAX Parser to get data from the XML file. When doing this LogCat shows the following error:

Data exceeds UNCOMPRESS_DATA_MAX (1290892 vs 1048576)

Is there anyway around this 1MB limit?

After a few Google searches, I found people who have split their files into 1MB chunks, but these weren't XML files so I am not sure how I would rejoin them before making the InputSource for my SAX Parser.

My file is not created by me, so I can't really edit it (although I may have to) and my code works if I retrieve it from Internet. Its around 1,300KB in size, so I want to not have to download it each time app run

解决方案

Is there anyway around this 1MB limit?

Give your file an extension that will not be compressed by aapt during the build process. For example, I think it skips compressing .mp3 files.