我正在创建一个Android应用程序棋盘游戏,一个大约5mb的字典文本文件,如何从raw或assets文件夹中读取此文件?
每当我尝试搜索字典时,我都会收到NullPointerException。
有关阅读和拆分大型词典文件的任何建议都会有所帮助。
答案 0 :(得分: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 ....已解决.. :-)