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:Main.java

public static void requestBackup(Context context) {
    if (NEED_BACKUP) {
        BackupManager backupManager = new BackupManager(context);
        backupManager.dataChanged();//from  ww  w. ja va 2 s.  com
    }
}

From source file:Main.java

/**
 * Notify the backup manager that out database is dirty.
 *
 * <P>This does not force an immediate backup.
 *
 * @param context application context/*from   www.  ja v  a 2 s.c o  m*/
 */
public static void dataChanged(Context context) {
    if (sBackupManager == null) {
        sBackupManager = new BackupManager(context);
    }
    sBackupManager.dataChanged();
}

From source file:Main.java

public static synchronized void initialize(final Context context) {
    mContext = context;/*w  w  w .  j  a  v a 2s  . c om*/
    mBM = new BackupManager(context);

    checkBackupApiKey();
    checkBackupAgent();

}

From source file:com.tasomaniac.muzei.history.ui.settings.SettingsFragment.java

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

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

protected static void storeDevices(Context context, SharedPreferences sp, ArrayList<JSONObject> devicesArr) {
    Set<String> devices = new HashSet<String>();
    for (JSONObject deviceJObj : devicesArr)
        devices.add(deviceJObj.toString());
    sp.edit().putStringSet(KEY_DEVICES, devices).commit();
    (new BackupManager(context)).dataChanged();
}

From source file:net.potterpcs.recipebook.RecipeEditor.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recipeeditor);
    backupManager = new BackupManager(this);

    recipeData = ((RecipeBook) getApplication()).getData();

    manager = getSupportFragmentManager();
    sslistview = (ListView) findViewById(R.id.ssfragmentlist);
    ssfragmentframe = (FrameLayout) findViewById(R.id.ssfragment);
    fragmentnames = getResources().getStringArray(R.array.fragmentnames);

    // Load the recipe if needed, and old state if it's there
    if (recipe == null) {
        recipeId = Long.parseLong(getIntent().getData().getLastPathSegment());

        if (savedInstanceState != null) {
            recipeId = savedInstanceState.getLong(SAVED_RECIPE_ID, recipeId);
        }//  w  ww  .  j av a 2 s  . co m

        if (recipeId != -1) {
            recipe = recipeData.getSingleRecipeObject(recipeId);
        } else {
            recipe = new Recipe();
            recipe.id = -1;
        }
    } else {
        recipeId = recipe.id;
    }

    if (sslistview != null) {
        // Do all the fragment setup stuff here. In testing versions,
        // there was a separate mode for 10" tablets. That mode didn't
        // use a list of editors, but showed them all on screen at once.
        // I might put that mode back in later on, so the list-mode
        // check will stay in.
        FragmentTransaction setup = manager.beginTransaction();
        //         Log.v(TAG, "creating fragments");

        meta = (MetadataEditor) manager.findFragmentByTag(ALL_FRAGMENT_NAMES[METADATA]);
        if (meta == null) {
            //            Log.v(TAG, "creating meta");
            meta = new MetadataEditor();
            setup.add(R.id.ssfragment, meta, ALL_FRAGMENT_NAMES[METADATA]);
        }
        //         Log.v(TAG, meta.toString());
        setup.hide(meta);

        ingredients = (IngredientsEditor) manager.findFragmentByTag(ALL_FRAGMENT_NAMES[INGREDIENTS]);
        if (ingredients == null) {
            //            Log.v(TAG, "creating ingredients");
            ingredients = new IngredientsEditor();
            setup.add(R.id.ssfragment, ingredients, ALL_FRAGMENT_NAMES[INGREDIENTS]);
        }
        //         Log.v(TAG, ingredients.toString());
        setup.hide(ingredients);

        directions = (DirectionsEditor) manager.findFragmentByTag(ALL_FRAGMENT_NAMES[DIRECTIONS]);
        if (directions == null) {
            //            Log.v(TAG, "creating directions");
            directions = new DirectionsEditor();
            setup.add(R.id.ssfragment, directions, ALL_FRAGMENT_NAMES[DIRECTIONS]);
        }
        //         Log.v(TAG, directions.toString());
        setup.hide(directions);

        tags = (TagsEditor) manager.findFragmentByTag(ALL_FRAGMENT_NAMES[TAGS]);
        if (tags == null) {
            //            Log.v(TAG, "creating tags");
            tags = new TagsEditor();
            setup.add(R.id.ssfragment, tags, ALL_FRAGMENT_NAMES[TAGS]);
        }
        //         Log.v(TAG, tags.toString());
        setup.hide(tags);

        photo = (PhotoEditor) manager.findFragmentByTag(ALL_FRAGMENT_NAMES[PHOTO]);
        if (photo == null) {
            //            Log.v(TAG, "creating photo");
            photo = new PhotoEditor();
            setup.add(R.id.ssfragment, photo, ALL_FRAGMENT_NAMES[PHOTO]);
        }
        //         Log.v(TAG, photo.toString());
        setup.hide(photo);

        setup.commit();

        sslistview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String itemText = ((TextView) view).getText().toString();

                lastFragment = nextFragment;

                if (itemText.equals(fragmentnames[METADATA])) {
                    nextFragment = meta;
                } else if (itemText.equals(fragmentnames[INGREDIENTS])) {
                    nextFragment = ingredients;
                } else if (itemText.equals(fragmentnames[DIRECTIONS])) {
                    nextFragment = directions;
                } else if (itemText.equals(fragmentnames[TAGS])) {
                    nextFragment = tags;
                } else if (itemText.equals(fragmentnames[PHOTO])) {
                    nextFragment = photo;
                } else {
                    nextFragment = null;
                }

                if (nextFragment != null && !nextFragment.equals(lastFragment)) {
                    FragmentTransaction ft = manager.beginTransaction();
                    if (lastFragment != null) {
                        ft.hide(lastFragment);
                    }
                    ft.show(nextFragment);
                    ft.commit();
                }
            }
        });
    }
}

From source file:com.rickendirk.rsgwijzigingen.MainFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1874) {
        //Nieuwe backup van instellingen doen
        BackupManager bm = new BackupManager(getActivity());
        bm.dataChanged();/*  ww  w  . j  a  v a2 s.c  om*/
    }
}

From source file:at.jclehner.rxdroid.RxDroid.java

public static void notifyBackupDataChanged() {
    new BackupManager(getContext()).dataChanged();
    Log.i(TAG, "notifyBackupDataChanged");
}

From source file:com.s16.inputmethod.skeyboard.IMESettings.java

public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    (new BackupManager(getActivity())).dataChanged();

    if (key.equals(APPLICATRION_ICON_KEY)) {
        boolean defaultAppIcon = getResources().getBoolean(R.bool.default_application_icon);
        if (prefs.getBoolean(APPLICATRION_ICON_KEY, defaultAppIcon)) {
            KeyboardApp.ShowApplicationIcon(getActivity().getApplicationContext());
        } else {/*from  w w w  . j a v  a  2  s  .  co m*/
            KeyboardApp.HideApplicationIcon(getActivity().getApplicationContext());
        }
    }

    updateLanguageKeySummary();
    updateKeyboardLayoutSummary();
    updateTextSizeSummary();
    updateShowExtendedRowSummary();
}

From source file:com.google.android.apps.dashclock.configuration.ConfigureAppearanceFragment.java

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

    final SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
    for (String key : mCurrentStyleNames.keySet()) {
        sp.putString(key, mCurrentStyleNames.get(key));
    }/*from  ww  w.  j  av  a 2  s .c o m*/
    sp.commit();

    new BackupManager(getActivity()).dataChanged();
}