android - 在 Android 中初始化一个大的常量数据结构

我必须初始化一个大的常量数据结构,但我收到编译器错误消息:

The code of constructor MS_XXX(String) is exceeding the 65535 bytes limit

这就是代码的样子:
   public class MD_XXX {

        public List<String> allElements; 

        public MD_XXX(String language) {
            this.allElements = new ArrayList<String>();


            if (...) {
                /* 0 */    allElements.add("some text0");
                /* 1 */    allElements.add("some text1");
                /* 2 */    allElements.add("some text2");
 .. many more lines here



我还有更多要初始化的数据结构,将其放入数据库中确实很麻烦 - 而且,这是 secret 信息。

解决这个问题的最佳方法是什么?
我真的必须将其分解为几个类文件或从数据库中读取吗?
我真的尽量避免使用 DB 方式,因为这些数据对应用程序来说应该是安全的。

非常感谢

最佳答案

Do I really have to break this up into several class files



将其拆分为几种方法可能就足够了。添加一些您从该超长构造函数调用的私有(private)方法,并将部分代码移到那里。每个方法的长度可以是 65535 字节。

https://stackoverflow.com/questions/8277650/

相关文章:

asp.net - 加载共享类库时出错

java - 复选框编译错误

ios - Amazon IOS SDK : compiler warnings - ARC iss

iphone - 编译我的应用程序没有错误,但是在设备上编译时挂起

java - 编译Java项目时出错

android - Dalvik格式失败,在ServerAssistant上出现错误1

c++ - C++/LabVIEW互操作: error extracting data from L

.net - 错误: “Expression must have class type” C++/C

visual-studio-2010 - 未注册库时,无法使用引用的TLB编译.NET应用程序

android - Android Intent使用情况(Call_action和new_task_