Delete a row from Parse Table

android, parse-platform

Solution

Basically, when you use 'new ParseObject("Favourite");' it will construct a new ParseObject. This parseObject does not exist in your database until you call any variant of .save() on it. Hence when you do this

    ParseObject favtagobject = new ParseObject("Favourite");
         favtagobject.put("Tag", "#" + keyword);
            favtagobject.put("User", ParseUser.getCurrentUser());
            favtagobject.deleteInBackground(new DeleteCallback() {

                @Override
                public void done(com.parse.ParseException arg0) {
                    // TODO Auto-generated method stub
                    System.out.println("deleted the tag succesfully");
                }
            });

All you're doing is creating a new object, that does not exist in your database and then try to delete it? What you're looking for is this

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Favourite");
    query.whereEqualTo("Tag", "#" + keyword);
    query.whereEqualTo("User", ParseUser.getCurrentUser());
    query.getFirstInBackground(new FindCallBack() {

            @Override
            public void done(ParseObject object, com.parse.ParseException arg0) {
               // TODO Auto-generated method stub
                   object.delete();
                   object.saveInBackground();
            }
        }););

This will first get the object from your database and then delete the row from table and save the changes made to the object!

Problem

I have a table called Favourite tags. it has fields - Tag, User( Pointer- respectiv user objectid).where User can store a tag and along with user-objectid as pointer in user filed and user remove the tag from favourite For Storing/Updating: it is working fine . ``` ParseObject favtagobject = new ParseObject("Favourite"); favtagobject.put("Tag", "#" + keyword); favtagobject.put("User", ParseUser.getCurrentUser()); favtagobject.saveInBackground(); ``` For removing/deleting the tag from table: Below code is not working ``` ParseObject favtagobject = new ParseObject("Favourite"); favtagobject.put("Tag", "#" + keyword); favtagobject.put("User", ParseUser.getCurrentUser()); favtagobject.deleteInBackground(new DeleteCallback() { @Override public void done(com.parse.ParseException arg0) { // TODO Auto-generated method stub System.out.println("deleted the tag succesfully"); } }); ``` i want to delete a row from table i know which row to be deleted. Please help me out.

Original source