【问题标题】:Objects still in localstore after unpinAllInBackground(List<...>, DeleteCallback)unpinAllInBackground(List<...>, Delete Callback) 后对象仍在本地存储中
【发布时间】:2015-05-29 15:07:37
【问题描述】:

我在我的 Android 应用中使用 Parse.com。我正在制作一个协作购物清单,允许用户将项目标记为删除(它们变成灰色),但只有当我按下同步按钮时它们才会被实际删除(并且有可用的网络)。目前,对象已从解析数据库中删除,但并未从本地数据存储中删除。我正在尝试这个:

 ParseQuery<ShoppingItem> queryDeletes = ShoppingItem.getQuery();
    queryDeletes.fromPin(MyApplication.ALL_ITEMS);
    queryDeletes.whereEqualTo("isDeleted", true);
    queryDeletes.findInBackground(new FindCallback<ShoppingItem>() {
        @Override
        public void done(final List<ShoppingItem> items, ParseException e) {
            if (e == null) {
                ShoppingItem.deleteAllInBackground(items, new DeleteCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e == null) {
                            ShoppingItem.unpinAllInBackground(items, new DeleteCallback() {
                                @Override
                                public void done(ParseException e) {
                                    if (e == null) {
                                        if (!isFinishing()) { 
                                           shoppingListAdapter.loadObjects(); // update the list view
                                        }
                                    }
                                }
                            });
                        }
                    }
                });
            }
        }
    });
}

已尝试清除应用程序数据并覆盖 ShoppingItem 中的 equals(),但没有成功。有什么想法吗?

谢谢!

【问题讨论】:

    标签: android parse-platform local-datastore


    【解决方案1】:

    好的,所以我解决了。据我了解,我试图做的事情是不可能使用解析库的。

    首先,deleteAllInBackground() 也取消固定对象,因此不需要unpinAllInBackground()。

    问题是我使用item.pin(MyApplication.ALL_ITEMS) 固定对象,因此取消固定它们的唯一方法是使用item.unpinInBackground(MyApplication.ALL_ITEMS) 传递固定名称。但是,批处理版本不允许将项目集合和引脚名称作为参数传递。因此,无法使用命名 pin 批量取消固定项目。

    我最终通过 pin 名称逐个取消固定对象。我最大的抱怨是,在没有 pin 名称的情况下执行 item.unpinInBackground() 不会引发异常,因此我不知道问题出在哪里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-21
      • 2021-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多