Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse local datastore query takes time on Android

I have pinned object for first time. Next time i try to fetch same object it takes time sometimes like 5 to 6 second in this the screen turns blank.

Here is my code for pinning. (Both pinning and querying data from local store is done on same table in parse)

ParseQuery<ParseObject> query = ParseQuery.getQuery(PARSE_IMAGE_TABLE);
List<ParseObject> images = query.find();

for each image i get i do following:

parseObject.pinInBackground(PARSE_PIN_WALLPAPER_INFO,
                            new SaveCallback() {

                                @Override
                                public void done(ParseException arg0) {
                                    System.out.println();

                                }
                            });

When querying:

ParseQuery<ParseObject> query = ParseQuery.getQuery(PARSE_IMAGE_TABLE);
        query.whereEqualTo(PARSE_IMAGE_THUMB_URL, imageURL);
        query.fromLocalDatastore();
        query.fromPin();

List<ParseObject> images = query.find(); -- this call takes time
like image 282
virendrao Avatar asked Aug 05 '26 18:08

virendrao


1 Answers

Yes their is a lot of performance tweaks you can do in your code. Pinning a list of objects is faster and better approach.

Instead of using find query use findInBackground.

Also start using pin(String name) and fromPin(String name) instead of fromPin() and fromPin(String name). This has a huge advantage if you have a lot of rows in your parse local storage.

like image 108
Sanchit Avatar answered Aug 08 '26 13:08

Sanchit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!