【问题标题】:How can I read a text file greater than 5mb from android raw folder?如何从 android raw 文件夹中读取大于 5mb 的文本文件?
【发布时间】:2013-02-01 01:57:45
【问题描述】:

我正在创建一个安卓应用棋盘游戏,它是一个大约 5mb 的字典文本文件,我如何从 raw 或 assets 文件夹中读取这个文件?

每当我尝试搜索字典时,我都会收到 NullPointerException。

任何有关阅读和拆分大型字典文件的建议都会有所帮助。

【问题讨论】:

  • 原始资源的大小限制为 1MB 未压缩。你的文件是什么格式的?如果它是基于文本的,请考虑将其放入 sqlite/FTS 表中,并让 sqlite 为您管理内存和索引。

标签: android file text dictionary


【解决方案1】:
Are You Running your App in Android Version below 2.2..
if yes then there is a limitation of 1MB max in Assets 
or Raw Folder..but in later version there is no restriction 
like this..so if you are able to run your code in later version
then that might be the ISSUE..i it does'nt show Nullpointer 
Exception ,It show Unable To compress large Data..kind of 
Exception... if this is the your can simply resolve this by
changing it to already Compress Format..these are Some Alredy 
Compressed Formet DVM Does'nt compress these formet..and you 
can use it,if it is Greater than !MB..
static const char* kNoCompressExt[] = {
".jpg", ".jpeg", ".png", ".gif",
".wav", ".mp2", ".mp3", ".ogg", ".aac",
".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
".amr", ".awb", ".wma", ".wmv"

};所以只需将文件扩展名 .txt 更改为 .jet.. 已解决..:-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-05
    • 2018-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多