public void saveData(AVUser mAvUser) { mAvUser.put("selectSubjectName", selectSubjectName); mAvUser.put("selectSubjectId", selectSubjectId); mAvUser.saveInBackground( new SaveCallback() { @Override public void done(AVException arg0) { // TODO Auto-generated method stub if (arg0 == null) { ShareTools.getInstance() .saveInitMemory(LoginInitMemory.this, selectSubjectId, selectSubjectName); Intent intent = new Intent(); intent.setClass(LoginInitMemory.this, MainHomeActivity.class); Bundle mBundle = new Bundle(); mBundle.putString("subject_id", selectSubjectId); mBundle.putString("subject_name", selectSubjectName); intent.putExtras(mBundle); startActivity(intent); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); LoginInitMemory.this.finish(); } else { Toast.makeText( LoginInitMemory.this, "初始化失败,请重试" + arg0.getMessage(), Toast.LENGTH_SHORT) .show(); } } }); }
private void saveToCloud() { try { JSONArray array = new JSONArray(); for (WrapGroup group : groups) { JSONObject object = new JSONObject(); object.put("groupid", group.getGroupid()); object.put("title", group.getGroup().getTitle()); object.put("imageurl", group.getGroup().getImageurl()); object.put("url", group.getGroup().getUrl()); array.put(object); } AVUser user = AVUser.getCurrentUser(); user.put("groups", array); user.saveInBackground( new SaveCallback() { @Override public void done(AVException e) { if (e == null) { showSnackBar("云端同步完成"); } } }); } catch (JSONException e) { e.printStackTrace(); KLog.e(e); } }
public static void saveAvatar(String path) throws IOException, AVException { AVUser user = AVUser.getCurrentUser(); final AVFile file = AVFile.withAbsoluteLocalPath(user.getUsername(), path); file.save(); user.put(User.AVATAR, file); user.save(); user.fetch(); }
public static void updateUserInfo() { AVUser user = AVUser.getCurrentUser(); if (user != null) { AVInstallation installation = AVInstallation.getCurrentInstallation(); if (installation != null) { user.put(User.INSTALLATION, installation); user.saveInBackground(); } } }