【发布时间】:2016-07-01 11:32:34
【问题描述】:
我有一个无法解决的问题;网上搜了下,没找到准确的解决办法,或者至少不是很了解,不知道。
无论如何,我有 Android Studio v. 2.1,这就是我想要做的:
起初,我创建了一个覆盖onCreate 方法的SQLite 数据库,然后,在同一方法的另一个覆盖中,我编写了一个检查数据库是否为空的方法;如果属实,它将增加大约 300000 个单词。
这是这一部分:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Database db = new Database(getApplicationContext());
db.open();
if (db.queryTutteParole().getCount() == 0) {
db.inserisciParole("pane", "no");
db.inserisciParole("latte", "no");
db.inserisciParole("uovo", "no");
db.inserisciParole("farina", "no");
db.inserisciParole("sale", "no");
//and all the remaining words
}
db.close();
}
澄清一下:queryTutteParole() 是一种返回数据库中所有内容的游标的方法,inserisciParole() 将单词及其值放入数据库中。
好吧,代码没有错误(我只测试了 5 个单词),但是如果我把 300000 多个单词全部放入并尝试在我的设备上运行它,我会遇到以下错误:
Here's the image with the errors
我该怎么办?
谢谢:)
【问题讨论】:
-
逐渐增加字数,看看错误从哪里开始。
-
请在帖子中添加SQL标签。
-
我会尝试将这些单词添加到字符串数组并遍历它。
-
类中常量、字段、方法和其他东西的最大数量约为 65k (2^16)
-
@babadaba 我已经尝试过了,但它给出了同样的错误(事实上,首先我已经这样做了,而不是我尝试使用 db)
标签: java android android-studio javac