Example usage for android.app.backup BackupDataInputStream getKey

List of usage examples for android.app.backup BackupDataInputStream getKey

Introduction

In this page you can find the example usage for android.app.backup BackupDataInputStream getKey.

Prototype

public String getKey() 

Source Link

Document

Report the key string associated with this entity within the backup data set.

Usage

From source file:com.csipsimple.backup.SipProfilesHelper.java

@Override
public void restoreEntity(BackupDataInputStream data) {
    if (ACCOUNTS_BACKUP_KEY.equalsIgnoreCase(data.getKey())) {
        try {/*from   w  w  w .j av  a  2 s .c om*/
            String profilesStr = readData(data);
            JSONArray accounts = new JSONArray(profilesStr);
            if (accounts != null && accounts.length() > 0) {
                SipProfileJson.restoreSipAccounts(mContext, accounts);
            }
        } catch (IOException e) {
            Log.e(THIS_FILE, "Cannot restore backup entry", e);
        } catch (JSONException e) {
            Log.e(THIS_FILE, "Cannot parse backup entry", e);
        }
    }
}

From source file:com.csipsimple.backup.SipSharedPreferencesHelper.java

@Override
public void restoreEntity(BackupDataInputStream data) {
    if (SETTINGS_BACKUP_KEY.equalsIgnoreCase(data.getKey())) {
        try {/*from   w w  w.  j  ava  2s . c om*/
            String settingsStr = readData(data);
            JSONObject settings = new JSONObject(settingsStr);
            if (settings != null) {
                SipProfileJson.restoreSipSettings(mContext, settings);
            }
            PreferencesWrapper pw = new PreferencesWrapper(mContext);
            pw.setPreferenceBooleanValue(PreferencesProviderWrapper.HAS_ALREADY_SETUP_SERVICE, true);
            pw.setPreferenceBooleanValue(PreferencesWrapper.HAS_ALREADY_SETUP, true);
        } catch (IOException e) {
            Log.e(THIS_FILE, "Cannot restore backup entry", e);
        } catch (JSONException e) {
            Log.e(THIS_FILE, "Cannot parse backup entry", e);
        }
    }
}