Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Self-Destructing Message Android App Retrieving and Viewing Messages Retrieving Messages

stage 7 challenge 2

Next, filter the query using a "where" clause. In this case, we want to filter episodes where the field "writer" is equal to the string value "Neil Gaiman".

MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseQuery;
import com.parse.ParseObject;
import com.parse.FindCallback;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /* Add code below! */
     ParseQuery<String> query = new ParseQuery<String>("DoctorWhoEpisodes"); 
      query.whereEqualTo(ParseConstants.KEY_RECIPIENT_IDS,ParseUser.getCurrentUser().getObjectId());  
    }
}

l need your help l am stuck...thank you in advance

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

If you look at the documentation for ParseQuery you will find the method being used here, whereEqualsTo(). Here is the relevant description from Parse.com:

public ParseQuery<T> whereEqualTo(String key, Object value)

Add a constraint to the query that requires a particular key's value to be equal to the provided value.

Parameters:

key - The key to check.

value - The value that the ParseObject must contain.

Returns:

Returns the query, so you can chain this call.

In our challenge we want to check to see where the field "writer" is equal to the string value "Neil Gaiman". Since we have already defined a ParseQuery object as query we can use:

query.whereEqualTo("writer", "Neil Gaiman");

I hope that helps and makes some sense.

Happy coding,

Ken

THANKS