Code example for AccountManager

Methods: getUserData

     * we received from the server - or 0 if we've never synced. 
     * @param account the account we're syncing 
     * @return the change high-water-mark 
    private long getServerSyncMarker(Account account) {
        String markerString = mAccountManager.getUserData(account, SYNC_MARKER_KEY);
        if (!TextUtils.isEmpty(markerString)) {
            return Long.parseLong(markerString);
        return 0; 
     * Save off the high-water-mark we receive back from the server. 
     * @param account The account we're syncing 
     * @param marker The high-water-mark we want to save. 
    private void setServerSyncMarker(Account account, long marker) {
        mAccountManager.setUserData(account, SYNC_MARKER_KEY, Long.toString(marker));
Contextual code suggestions in your IDE  Get Codota for Java