1

I used Parse.com to download and store data in local database (for my offline app).

The download progress is normal. However, when I pin all list objects into local by using pinAllInBackground, it took so long time on device and crash on Genymotion (outofmemory). My data is more than 10000 records and maybe more.

This is my code:

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();
                                }
                            });
                        }
                    }
                });
            }
        }
    };
}
CiKa
  • 11
  • 1
  • 1
  • I tried LocalDataStore previously and I faced with same issue - pinning around 100 of objects took 30 secs. – Oleg Osipenko May 07 '15 at 08:16
  • I had some of the same issues. I started using a real device and it helped a ton. Don't know how helpful this comment is, but thought i'd mention it. Also, what about pinning in chunks? – James Jones May 07 '15 at 14:08
  • @JamesJones - I tried pinning in chunks (every 50 records), it helped a little bit with preventing outofmemoryerror, but it was still very slow not only on genymotion but also in real device (Sony Z). Note: seem on Sony Z2 (Lolipop) the pinning time is reduced. – CiKa May 07 '15 at 15:26

0 Answers0