DbxRecord getRecord() { DbxRecord record = null; try { // We use getOrInsert to initialize the record to level 0. record = mDatastore .getTable("state") .getOrInsert("current_level", new DbxFields().set("level", 0.0)); } catch (DbxException e) { e.printStackTrace(); } return record; }
@Override public void onResume() { super.onResume(); // When the app resumes, open the datastore and start listening for changes. if (mDatastore == null && mAccountManager.hasLinkedAccount()) { try { mDatastore = DbxDatastore.openDefault(mAccountManager.getLinkedAccount()); DbxTable table = mDatastore.getTable("state"); table.setResolutionRule("level", DbxTable.ResolutionRule.MAX); mDatastore.addSyncStatusListener(mDatastoreListener); updateLevel(); } catch (DbxException e) { e.printStackTrace(); } } }