David Lasry
David Lasry

Reputation: 1417

retrieve all users from parse - android

I have a registered app on Parse with a signup/login system. Now I want to create an activity which grabs all the available users in the app and to display them one-by-one as a listview. Can someone tell me how can I do that?

Upvotes: 0

Views: 1315

Answers (1)

Mullazman
Mullazman

Reputation: 509

Once you've setup your ListView's adapter you can call this whenever you need to update it's contents:

public void updateUsers() {
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> userObjects, ParseException error) {
            if (userObjects != null) {
                mUserAdapter.clear();
                for (int i = 0; i < userObjects.size(); i++) {
                    mUserAdapter.add(userObjects.get(i));
                }
            }
        }
    });
}    

That updates my adapter which is plugged into my ListView. If you have more than 100 users you want to return you'll need to up the limit as I hear that's the default (then you have to page the results, not sure how yet)

Side note: As far as I know you can't Subclass the ParseUser at the moment (you can, but you then can't use that as the object you're querying with using ParseUser.getQuery() (Which would normally be done by ParseUser.getQuery(MyCustomUserClass.class) if you were to query a customised object.

Upvotes: 2

Related Questions