strings.xml 资源可以有多大?
How big can strings.xml resources be?
我看到 this post 说当 strings.xml
变得太大时应用程序可能会崩溃。我的 strings.xml
文件现在有 800 多行,过一会儿会更大。
post中的答案说使用SQLite数据库可以防止崩溃。
但在我的例子中,我有一个 SQLite 数据库,它从 strings.xml
中获取条目的数据,因为我的应用程序使用不同语言的语言环境。
我的问题是,strings.xml
可以有多大?如果我达到线路限制,我该怎么做才能防止崩溃?
Resources.get***
方法没有任何明确的限制,因此它取决于您设备的内存大小。据我所知,Android 的旧版本有 per process memory limitation.
没有strings.xml的限制。它更多的是加载字符串数组的问题。 getResources().getStringArray 函数并不意味着加载元素多于 512 的数组(更多信息请参见此处 Should I be using something other than getResource().getStringArray() to populate a large array?)但只要您不使用大数组就可以了。
我看到 this post 说当 strings.xml
变得太大时应用程序可能会崩溃。我的 strings.xml
文件现在有 800 多行,过一会儿会更大。
post中的答案说使用SQLite数据库可以防止崩溃。
但在我的例子中,我有一个 SQLite 数据库,它从 strings.xml
中获取条目的数据,因为我的应用程序使用不同语言的语言环境。
我的问题是,strings.xml
可以有多大?如果我达到线路限制,我该怎么做才能防止崩溃?
Resources.get***
方法没有任何明确的限制,因此它取决于您设备的内存大小。据我所知,Android 的旧版本有 per process memory limitation.
没有strings.xml的限制。它更多的是加载字符串数组的问题。 getResources().getStringArray 函数并不意味着加载元素多于 512 的数组(更多信息请参见此处 Should I be using something other than getResource().getStringArray() to populate a large array?)但只要您不使用大数组就可以了。