我使用Parse.com在本地数据库中下载和存储数据(对于我的离线应用程序)。
下载进度正常。但是,当我使用pinAllInBackground将所有列表对象固定到本地时,它在设备上花了很长时间并且在Genymotion(outofmemory)上崩溃。我的数据超过10000条记录,甚至更多。
这是我的代码:
private FindCallback getAllCardLocationRule(){
return new FindCallback<CardLocationRule>() {
@Override
public void done(final List<CardLocationRule> cardLocationRules, ParseException e) {
if (e == null) {
cardLocationRuleList.clear();
cardLocationRuleList.addAll(cardLocationRules);
final int limit = 1000;
ParseObject.pinAllInBackground(cardLocationRuleList, new SaveCallback() {
@Override
public void done(ParseException e) {
if (cardLocationRules.size() == limit) {
skip += limit;
Ln.i("myTrace: Skip: "+skip);
ParseQuery<CardLocationRule> query = ParseQuery.getQuery(CardLocationRule.class);
query.setSkip(skip);
query.setLimit(limit);
query.findInBackground(getAllCardLocationRule());
} else {
Ln.i("myTrace: Card Location Rule size: "+cardLocationRuleList.size());
ParseObject.pinAllInBackground(cardLocationRuleList, new SaveCallback() {
@Override
public void done(ParseException e) {
loadCards();
}
});
}
}
});
}
}
};
}