如何从android中的parse表中删除特定记录?

时间:2014-05-12 11:55:58

标签: android parse-platform

从解析表中删除特定记录。

deleteBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            ParseObject.createWithoutData("Country", objID)
                    .deleteEventually();
            Intent i = new Intent(SingleItemView.this, MainActivity.class);
            SingleItemView.this.finish();
            startActivity(i);
        }
    });

2 个答案:

答案 0 :(得分:3)

试试这个:

    ParseQuery<ParseObject> query = ParseQuery.getQuery(TABLE_NAME);
    query.whereEqualTo("groupname", groupName);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> invites, ParseException e) {
            if (e == null) {
                // iterate over all messages and delete them
                for(ParseObject invite : invites)
                {
                     invite.deleteInBackground();
                }
            } else {
                //Handle condition here
            }
        }
    });

答案 1 :(得分:1)

我不确定ParseObject。试试deleteInBackground()。 根据文档https://parse.com/docs/android/api/com/parse/ParseObject.html

deleteEventually() : Deletes this object from the server at some unspecified time in the future, even if Parse is currently inaccessible.

deleteInBackground() : Deletes this object on the server in a background thread.