Example usage for android.app.backup BackupManager BackupManager

List of usage examples for android.app.backup BackupManager BackupManager

Introduction

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

Prototype

public BackupManager(Context context) 

Source Link

Document

Constructs a BackupManager object through which the application can communicate with the Android backup system.

Usage

From source file:com.zns.comicdroid.activity.Add.java

@Override
public void onStop() {
    if (!mIsScanning) {
        if (mAdapter != null && mAdapter.getCount() > 0) {
            //Backup
            BackupManager m = new BackupManager(this);
            m.dataChanged();/*from w w  w.j av a 2 s  . c om*/
        }
    }
    super.onStop();
}

From source file:net.pmarks.chromadoze.ChromaDoze.java

@Override
protected void onPause() {
    super.onPause();

    // If the equalizer is silent, stop the service.
    // This makes it harder to leave running accidentally.
    if (mServiceActive && mUiState.getPhonon().isSilent()) {
        NoiseService.stopNow(getApplication(), R.string.stop_reason_silent);
    }//from   w w w. j  a v a  2s.c o  m

    SharedPreferences.Editor pref = getSharedPreferences(PREF_NAME, MODE_PRIVATE).edit();
    pref.clear();
    mUiState.saveState(pref);
    pref.commit();
    new BackupManager(this).dataChanged();

    // Stop receiving progress events.
    NoiseService.removePercentListener(this);
    mUiState.removeLockListener(this);
}

From source file:org.gdg.frisbee.android.onboarding.FirstStartActivity.java

private void requestBackup() {
    BackupManager bm = new BackupManager(this);
    bm.dataChanged();
}

From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java

private void saveActiveExtensionList() {
    StringBuilder sb = new StringBuilder();

    synchronized (mActiveExtensions) {
        for (ExtensionWithData ci : mActiveExtensions) {
            if (sb.length() > 0) {
                sb.append(",");
            }//  w w  w  .ja  v a  2  s  . c  o m
            sb.append(ci.listing.componentName.flattenToString());
        }
    }

    mDefaultPreferences.edit().putString(PREF_ACTIVE_EXTENSIONS, sb.toString()).commit();
    new BackupManager(mApplicationContext).dataChanged();
}

From source file:com.dwdesign.tweetings.app.TweetingsApplication.java

@Override
public void onCreate() {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mPreferences.registerOnSharedPreferenceChangeListener(this);
    super.onCreate();
    initializeAsyncTask();//w ww . j  a v a 2  s .  co  m
    GalleryUtils.initialize(this);
    mBrowserUserAgent = new WebView(this).getSettings().getUserAgentString();
    mServiceInterface = ServiceInterface.getInstance(this);
    registerPush();
    backupManager = new BackupManager(this);

}

From source file:com.piusvelte.taplock.client.core.TapLockService.java

@Override
public void onCreate() {
    super.onCreate();
    int currVer = 0;
    try {//from  ww  w . jav  a2  s. com
        currVer = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    SharedPreferences sp = (SharedPreferences) getSharedPreferences(KEY_PREFS, MODE_PRIVATE);
    if (!sp.contains(KEY_VERSION) || (currVer > sp.getInt(KEY_VERSION, 0))) {
        sp.edit().putInt(KEY_VERSION, currVer).commit();
        (new BackupManager(this)).dataChanged();
    }
    onSharedPreferenceChanged(getSharedPreferences(KEY_PREFS, MODE_PRIVATE), KEY_DEVICES);
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
}

From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java

/**
 * Stores a bunch of KnownLocations to preferences.  Note that this <b>replaces</b>
 * all currently-stored KnownLocations.//  w  ww .  j  a v  a2 s .c o m
 *
 * @param c a Context
 * @param locations a List of KnownLocations
 */
public static void storeKnownLocations(@NonNull Context c, @NonNull List<KnownLocation> locations) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    SharedPreferences.Editor edit = prefs.edit();

    JSONArray arr = new JSONArray();

    for (KnownLocation kl : locations) {
        arr.put(kl.serialize());
    }

    // Man, that's easy.
    edit.putString(GHDConstants.PREF_KNOWN_LOCATIONS, arr.toString());
    edit.apply();

    BackupManager bm = new BackupManager(c);
    bm.dataChanged();
}

From source file:com.tasomaniac.muzei.earthview.ui.SettingsFragment.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    final String launcherIntentKey = getString(R.string.pref_key_launcher_intent);
    if (isAdded() && launcherIntentKey.equals(s)) {

        final boolean hideLauncher = sharedPreferences.getBoolean(launcherIntentKey, false);
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(getActivity().getPackageName(), LAUNCHER_ACTIVITY_NAME),
                hideLauncher ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    }//from w ww  . j  av a 2 s  .c o  m
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.settings.PrefsActivity.java

@Override
protected void onDestroy() {
    // Request a backup in case prefs changed
    // Safe to call multiple times
    // TODO is this still useful?
    new BackupManager(this).dataChanged();
    super.onDestroy();
    getDelegate().onDestroy();//from  www  . j a  v a 2  s  . c  om
}

From source file:com.shalzz.attendance.fragment.SettingsFragment.java

public void requestBackup() {
    BackupManager bm = new BackupManager(mContext);
    bm.dataChanged();
}