取消固定后,数据将保留在本地数据存储中

Bru*_*uno 7 java android parse-platform

我无法解决问题,无法找到解决方案.我用这种方式固定数据:

myGroup = queryGroup.getFirst();
if (myGroup != null) {
    ParseObject.unpinAllInBackground("Groups", new DeleteCallback() {
        @Override
        public void done(ParseException arg0) {
            myGroup.pinInBackground("Groups", new SaveCallback() {
                @Override
                public void done(ParseException arg0) {
                    if (arg0 != null) {
                        Toast.makeText(getApplicationContext(), "ERROR", Toast.LENGTH_SHORT).show();
                        arg0.printStackTrace();
                    }
                }
            });
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

并试着取消它像这样:

ParseObject.unpinAllInBackground("Groups", new DeleteCallback() {
    @Override
    public void done(ParseException arg0) {
        if (arg0 == null) {
            dataDeleted();
        } else {
            arg0.printStackTrace();
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

但它不会抛出异常,当我开始查询时,数据仍然保存在本地.

Eva*_* R. 1

尝试删除本地数据并重试。我遇到了一些与固定相关的奇怪问题,结果发现我固定的对象中没有数据,这弄乱了固定。

使用以下代码,pinallinbackground可以工作,您是否可以尝试而不是迭代每个对象?:

query.findInBackground(new FindCallback<ParseObject>() {

      @Override
      public void done(final List<ParseObject> moves, final com.parse.ParseException e) {
        if (e == null) {
          if (debug) {
            Log.i("bjjMoves returned:", String.valueOf(moves.size()));
          }
          ParseObject.unpinAllInBackground("bjjMoves", new DeleteCallback() {
            public void done(ParseException e) {
              // Cache the new results.
              ParseObject.pinAllInBackground("BJJMove", moves);
            }
          });
Run Code Online (Sandbox Code Playgroud)

您会注意到我使用的是 PinAllInBackground,而不是 pininbackground。