Search code examples
javaandroidandroid-studioparse-platform

How do I retrieve info of other users in Parse in Android?


ive been trying for a long time and i cant manage to find a solution

in the User class in parse, I added a new column and called it bio, im trying to retrieve that so i can set it inside the user's profile TextView, inside of android studio ofc

        Intent intent = getIntent();
        String usersUsername = intent.getStringExtra("username");

        

        ParseQuery<ParseUser> bioQuery = ParseQuery.getQuery("User");
        bioQuery.whereEqualTo("username", usersUsername);
        bioQuery.getInBackground("bio", new GetCallback<ParseUser>() {
            @Override
            public void done(ParseUser object, ParseException e) {
                if (e == null){
                    Log.i("info", "happy");
                } else {
                    Log.i("info", "sad");
                }
            }
        });

im getting the right username with the intent, im getting it from a listview that hold the users usernames

i always get "sad", i tried multiple other ways and regarding those other ways it kept on telling me that there were no queries that match

please assist me, thank you.


Solution

  • for anyone looking for an answer to a question like mine, I managed to get a solution, which at second glance should've been obvious I took Davi's advice and added to it what I needed

    Intent intent = getIntent();
    String usersUsername = intent.getStringExtra("username");
    
    ParseQuery<ParseUser> bioQuery = ParseUser.getQuery();
            bioQuery.whereEqualTo("username", usersUsername);
            bioQuery.findInBackground(new FindCallback<ParseUser>() {
                @Override
                public void done(List<ParseUser> objects, ParseException e) {
                    if (e == null){
                        Log.i("info", "happy");
                        for(ParseUser user : objects){
                            Log.i("info", (String) user.get("bio"));
                            bio = (String) user.get("bio");
                        }
                        fullBioTextView.setText(bio);
                    } else {
                        Log.i("info", "sad");
                    }
                }
            });