android - 解析对象没有被删除(Android)

android - 解析对象没有被删除(Android),第1张

我正在尝试从我的parse.com类中删除一个对象" GameScore"其中playerName等于当前玩家名称。我成功检索了对象但是deleteInBackground函数对我不起作用。(对象没有从parse.com类中删除。我是新手解析和android两者。有人可以帮忙。

holder.deleteitem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            //String myname = worldpopulationlist.get(position).getName();

            ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
            query.whereEqualTo("playerName", worldpopulationlist.get(position).getName());
            query.getFirstInBackground(new GetCallback<ParseObject>() {

                @Override
                public void done(ParseObject object, ParseException e) {
                    // TODO Auto-generated method stub
                    if (object == null) {
                        Toast.makeText(context,"  not found",
                                Toast.LENGTH_SHORT).show();
                        } else {
                            object1.deleteInBackground(new DeleteCallback() {
                                           public void done(ParseException e) {
                                                 if (e == null) {
                                                     Toast.makeText(context,"  deleted",
                                                                Toast.LENGTH_SHORT).show();
                                                 } else {
                                                     Toast.makeText(context,"  not deleted",
                                                                Toast.LENGTH_SHORT).show();
                                                     e.printStackTrace();

                                                 }
                                               }
                                             });

                        }
                    }

            });
            Intent intent = new Intent(context, MainActivity.class);
            intent.setFlags( Intent.FLAG_ACTIVITY_NO_HISTORY);
            context.startActivity(intent);

        }


    });

这是错误日志。日志的第一行显示未找到的对象,但是当我使用object.getObjectId()方法时。它返回对象的正确objectId。

    07-15 07:21:14.688: I/message(17431): com.parse.ParseException: object not found for delete
07-15 07:21:14.688: I/message(17431):   at com.parse.ParseCommand.then(ParseCommand.java:340)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:442)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.execute(Task.java:67)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.completeImmediately(Task.java:439)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.continueWith(Task.java:316)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.continueWith(Task.java:327)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:377)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:474)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.execute(Task.java:67)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.completeAfterTask(Task.java:471)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:467)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:343)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.runContinuations(Task.java:502)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:498)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:557)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.setResult(Task.java:591)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:485)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:442)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.execute(Task.java:67)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.completeImmediately(Task.java:439)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:435)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:309)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.runContinuations(Task.java:502)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:498)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:557)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.setResult(Task.java:591)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:485)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:442)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.execute(Task.java:67)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.completeImmediately(Task.java:439)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.continueWith(Task.java:316)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.continueWith(Task.java:327)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:478)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.execute(Task.java:67)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.completeAfterTask(Task.java:471)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:467)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:343)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.then(Task.java:1)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.runContinuations(Task.java:502)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.access(Task.java:498)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:557)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task$TaskCompletionSource.setResult(Task.java:591)
07-15 07:21:14.688: I/message(17431):   at com.parse.Task.run(Task.java:225)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:150)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-15 07:21:14.688: I/message(17431):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-15 07:21:14.688: I/message(17431):   at java.lang.Thread.run(Thread.java:856)

最佳答案:

2 个答案:

答案 0 :(得分:4)

我遇到了类似的问题,我的问题是Parse ACL权限。

在类中,您最初创建对象的位置(不是要删除对象的类)。设置写权限如下:

    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true); //objects created are writable
    ParseACL.setDefaultACL(defaultACL, true);

答案 1 :(得分:0)

可能是deleteInBackground()正在返回错误,或者(在Android处理此方式时不确定)它在进行删除之前被垃圾收集。

考虑向删除添加回调,以至少记录删除中的成功/错误。

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复