skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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");
                    }
                }
            });
    

  2. Try with findInBackground. It should be something like:

    Intent intent = getIntent();
            String usersUsername = intent.getStringExtra("username");
    
            
    
            ParseQuery<ParseUser> bioQuery = ParseQuery.getQuery(ParseUser);
            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");
                    } else {
                        Log.i("info", "sad");
                    }
                }
            });
    

    You also need to make sure that you have access to the user. If it is not the current logged in user, you probably do not have access.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search