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 Self-Destruction Deleting the Whole Message

3,311 Points

Cannot delete object: E/Delete Error﹕ object not found for delete

So I am trying to delete a comment object in my own app that I am writing. And the object won't delete. In the log cat it says: "E/Delete Error: object not found for delete" How do I fix this? Here is my code:

public class PostThreadActivity extends ListActivity {

    private SwipeRefreshLayout mSwipeRefreshLayout;
    private ParseQueryAdapter<Comment> mainCommentAdapter;
    private CommentAdapter favoriteCommentAdapter;
    protected List<ParseObject> mComments; //create this member variable in order be able to delete comments

    public void onCreate(Bundle savedInstanceState) {

        Intent i = getIntent();
        //Get the result of
        String title = i.getStringExtra("title");
        String location = i.getStringExtra("location");
        String description = i.getStringExtra("description");
        String rating = i.getStringExtra("ratings");
        //String photo = i.getStringExtra("photo");

        //TextViews of the singleItems
        TextView titleTextView = (TextView) findViewById(R.id.title);  //Get the textView for the title from item_list_favorites.xml and convert it to a variable titleTextView. Then gets the submitted Event title info from getters and setters: getTitle, then set it as text of TitleTextView //simple.
        TextView locationTextView = (TextView) findViewById(R.id.location);
        TextView descriptionTextView = (TextView) findViewById(R.id.description);
        TextView ratingTextView = (TextView) findViewById(R.id.rating);

        /*ParseImageView mealImage = (ParseImageView) findViewById(R.id.icon_in_post);

        ParseFile photoFile = meal.getParseFile();
        if (photoFile != null) {
            mealImage.loadInBackground(new GetDataCallback() {
                public void done(byte[] data, ParseException e) {
                    // nothing to do

        mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);

        mainCommentAdapter = new ParseQueryAdapter<Comment>(this, Comment.class);

        favoriteCommentAdapter = new CommentAdapter(this);

        // Default view is all comments
        final ListView commentsListView = (ListView) findViewById(android.R.id.list);

        //adapt to show favorites adapter view

        getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final Comment item = favoriteCommentAdapter.getItem(position);

                        "Click ListItem Number " + position, Toast.LENGTH_LONG)

                AlertDialog.Builder builder = new AlertDialog.Builder(PostThreadActivity.this);
                builder.setTitle("DELETE COMMENT");
                builder.setMessage("Are you sure you want to delete this comment?");
                builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // Delete the comment
                        item.deleteInBackground(new DeleteCallback() {
                            public void done(ParseException e) {
                                Log.e("Delete Error", e.getMessage());

                builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing
                AlertDialog alert = builder.create();