Java 类android.app.backup.BackupManager 实例源码

项目:simple-keyboard    文件:SubScreenFragment.java   
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
项目:buildAPKsSamples    文件:BackupRestoreActivity.java   
/** Set up the activity and populate its UI from the persistent data. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** Establish the activity's UI */
    setContentView(R.layout.backup_restore);

    /** Once the UI has been inflated, cache the controls for later */
    mFillingGroup = (RadioGroup) findViewById(R.id.filling_group);
    mAddMayoCheckbox = (CheckBox) findViewById(R.id.mayo);
    mAddTomatoCheckbox = (CheckBox) findViewById(R.id.tomato);

    /** Set up our file bookkeeping */
    mDataFile = new File(getFilesDir(), BackupRestoreActivity.DATA_FILE_NAME);

    /** It is handy to keep a BackupManager cached */
    mBackupManager = new BackupManager(this);

    /**
     * Finally, build the UI from the persistent store
     */
    populateUI();
}
项目:AOSP-Kayboard-7.1.2    文件:SubScreenFragment.java   
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
            final SubScreenFragment fragment = SubScreenFragment.this;
            final Context context = fragment.getActivity();
            if (context == null || fragment.getPreferenceScreen() == null) {
                final String tag = fragment.getClass().getSimpleName();
                // TODO: Introduce a static function to register this class and ensure that
                // onCreate must be called before "onSharedPreferenceChanged" is called.
                Log.w(tag, "onSharedPreferenceChanged called before activity starts.");
                return;
            }
            new BackupManager(context).dataChanged();
            fragment.onSharedPreferenceChanged(prefs, key);
        }
    };
    getSharedPreferences().registerOnSharedPreferenceChangeListener(
            mSharedPreferenceChangeListener);
}
项目:dashbar    文件:ExtensionManager.java   
/**
 * Replaces the set of active extensions with the given list.
 */
public void setInternalActiveExtensions(List<ComponentName> extensions) {
    StringBuilder sb = new StringBuilder();

    for (ComponentName extension : extensions) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        sb.append(extension.flattenToString());
    }

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

    mInternalActiveExtensions.clear();
    mInternalActiveExtensions.addAll(extensions);
    setActiveExtensions(getActiveExtensionNames());
}
项目:dashbar    文件:ConfigureAdvancedFragment.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    if (isAdded() && AppearanceConfig.PREF_SETTINGS_BUTTON.equals(key)) {
        boolean enableLauncher = AppearanceConfig.PREF_SETTINGS_BUTTON_IN_LAUNCHER.equals(
                sp.getString(AppearanceConfig.PREF_SETTINGS_BUTTON, null));
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(
                        getActivity().getPackageName(),
                        ConfigurationActivity.LAUNCHER_ACTIVITY_NAME),
                enableLauncher
                        ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}
项目:geohashdroid    文件:PreferencesScreen.java   
@Override
public void onStop() {
    // If something changed, tell WikiService to kick back in.  Don't
    // worry; if WikiService isn't paused, this won't do anything, and
    // if it's stopped for any other reason, it'll stop again when this
    // comes in.
    if(mHasChanged) {
        mHasChanged = false;
        Intent i = new Intent(getActivity(), WikiService.class);
        i.putExtra(QueueService.COMMAND_EXTRA, QueueService.COMMAND_RESUME);
        getActivity().startService(i);
    }

    BackupManager bm = new BackupManager(getActivity());
    bm.dataChanged();

    super.onStop();
}
项目:geohashdroid    文件:BaseGHDThemeActivity.java   
/**
 * <p>
 * Sets whether or not the app is in night mode.
 * </p>
 *
 * <p>
 * <b>NOTE:</b> If the state of night mode changes, <b>the Activity WILL be
 * recreated</b>, as that's the only way you can change themes on-the-fly.
 * Make sure you've done whatever you need to BEFORE calling this, as there
 * is NO guarantee execution will meaningfully continue past this!
 * </p>
 *
 * @param night true to be night, false to be not night
 */
protected void setNightMode(boolean night) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // Remember, ONLY act on this if this changed at all!
    if(prefs.getBoolean(GHDConstants.PREF_NIGHT_MODE, false) != night) {
        SharedPreferences.Editor edit = prefs.edit();
        edit.putBoolean(GHDConstants.PREF_NIGHT_MODE, night);
        edit.apply();

        BackupManager bm = new BackupManager(this);
        bm.dataChanged();

        recreate();
    }
}
项目:geohashdroid    文件:CentralMap.java   
private void updateLastGraticule(@NonNull Info info) {
    // This'll just stash the last Graticule away in preferences so we can
    // start with the last-used one if preferences demand it as such.
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor edit = prefs.edit();

    edit.putBoolean(GHDConstants.PREF_DEFAULT_GRATICULE_GLOBALHASH, info.isGlobalHash());
    Graticule g = info.getGraticule();

    if(g != null) {
        edit.putString(GHDConstants.PREF_DEFAULT_GRATICULE_LATITUDE, g.getLatitudeString(true));
        edit.putString(GHDConstants.PREF_DEFAULT_GRATICULE_LONGITUDE, g.getLongitudeString(true));
    }

    edit.apply();

    BackupManager bm = new BackupManager(this);
    bm.dataChanged();
}
项目:geohashdroid    文件:KnownLocation.java   
/**
 * Stores a bunch of KnownLocations to preferences.  Note that this <b>replaces</b>
 * all currently-stored KnownLocations.
 *
 * @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();
}
项目:dashclock    文件:ExtensionManager.java   
/**
 * Replaces the set of active extensions with the given list.
 */
public void setInternalActiveExtensions(List<ComponentName> extensions) {
    StringBuilder sb = new StringBuilder();

    for (ComponentName extension : extensions) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        sb.append(extension.flattenToString());
    }

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

    mInternalActiveExtensions.clear();
    mInternalActiveExtensions.addAll(extensions);
    setActiveExtensions(getActiveExtensionNames());
}
项目:dashclock    文件:ConfigureAdvancedFragment.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    if (isAdded() && AppearanceConfig.PREF_SETTINGS_BUTTON.equals(key)) {
        boolean enableLauncher = AppearanceConfig.PREF_SETTINGS_BUTTON_IN_LAUNCHER.equals(
                sp.getString(AppearanceConfig.PREF_SETTINGS_BUTTON, null));
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(
                        getActivity().getPackageName(),
                        ConfigurationActivity.LAUNCHER_ACTIVITY_NAME),
                enableLauncher
                        ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}
项目:MuzeiEarthView    文件: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);
    }
}
项目:SeriesGuideToPlex    文件: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);
    packageManager.setComponentEnabledSetting(
        new ComponentName(
            getActivity().getPackageName(),
            LAUNCHER_ACTIVITY_NAME),
        hideLauncher
            ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
            : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
        PackageManager.DONT_KILL_APP);
  }
}
项目:android-device-identification    文件:UserIdentifier.java   
public static String getUserID(Context context) {
    if (uniqueID == null) {
        SharedPreferences sharedPrefs = context.getSharedPreferences(SimpleBackupAgent.PREFS, Context.MODE_PRIVATE);
        uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
        if (uniqueID == null) {
            uniqueID = UUID.randomUUID().toString();
            SharedPreferences.Editor editor = sharedPrefs.edit();
            editor.putString(PREF_UNIQUE_ID, uniqueID);
            editor.commit();

            //backup the changes
            BackupManager mBackupManager = new BackupManager(context);
            mBackupManager.dataChanged();
        }
    }

    return uniqueID;
}
项目:Noyze    文件:ConfigurationActivity.java   
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    LOGI(TAG, "onSharedPreferenceChanged(" + key + ')');
    Context context = getApplicationContext();
    if (null != context) {
        (new BackupManager(context)).dataChanged();
    }

    if (Constants.PREF_VOLUME_PANEL.equals(key)) {
        // TRACK: what theme is being used.
        String panel = sharedPreferences.getString(key, StatusBarVolumePanel.TAG);
        VolumeAccessibilityService.VolumePanelChangeEvent event =
                new VolumeAccessibilityService.VolumePanelChangeEvent(panel, Utils.supportsMediaPlayback(panel));
        onVolumePanelChangeEvent(event);
    } else if (Constants.PREF_REPORTING.equals(key)) {
        // TRACK: when the user opts out of being tracked.
    }
}
项目:cowbird    文件:ProtocolDBContentProvider.java   
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    int count = 0;
    switch (vrUrl) {
        case URLProtocol:
            count = db.getWritableDatabase().delete(Protocol.TABLE_NAME, selection, selectionArgs);
            if (count > 0) {
                new BackupManager(getContext()).dataChanged();
            }
            break;
    }
    getContext().getContentResolver().notifyChange(uri, null);

    // Returns the number of rows deleted.
    return count;
}
项目:cowbird    文件:ProtocolDBContentProvider.java   
@Override
public Uri insert(Uri uri, ContentValues values) {
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    long rowId = -1;
    switch (vrUrl) {
        case URLProtocol:
            rowId = db.getWritableDatabase().insert(Protocol.TABLE_NAME, null, values);
            new BackupManager(getContext()).dataChanged();
            break;
        default:
            throw new SQLiteConstraintException("Failed to switch insert protocol " + uri);

    }

    // If the insert succeeded, the row ID exists.
    if (rowId > 0) {
        // Creates a URI with the note ID pattern and the new row ID appended to it.
        Uri noteUri = ContentConstants.getUriFor(vrUrl, rowId);

        // Notifies observers registered against this provider that the data changed.
        getContext().getContentResolver().notifyChange(noteUri, null);
        return noteUri;
    } else {
        throw new SQLiteConstraintException("Failed to insert row into " + uri);
    }
}
项目:cowbird    文件:ProtocolDBContentProvider.java   
@Override
public int update(Uri uri, ContentValues values, String selection,
                  String[] selectionArgs) {
    int count = 0;
    ContentConstants.ProtocolURLs vrUrl = convertURIToProtocolURL(uri);
    switch (vrUrl) {
        case URLProtocol:
            SQLiteDatabase sql = db.getWritableDatabase();
            count = sql.update(Protocol.TABLE_NAME, values, selection, selectionArgs);
            if (count > 0) {
                new BackupManager(getContext()).dataChanged();
            }
            break;
    }

    getContext().getContentResolver().notifyChange(uri, null);
    return count;

}
项目:dscautorename    文件:DSCApplication.java   
/**
 * Called when the application is starting, before any activity, service, or
 * receiver objects (excluding content providers) have been created.
 */
@Override
public void onCreate() {
    super.onCreate();
    checkApplicationResources();
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mBackupManager = new BackupManager(this);
    initLocale();
    mSdkInt = android.os.Build.VERSION.SDK_INT;
    int serviceType = getServiceType();
    if (DSCApplication.SERVICE_TYPE_DISABLED != serviceType) {
        checkRegisteredServiceType(false);
    }
    mFolderObserverMap = new HashMap<>();
    if (SERVICE_TYPE_FILE_OBSERVER == serviceType) {
        initVolumes();
        initFolderObserverList(false);
    }
}
项目: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);
    }

    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);
}
项目:Key-Value-Backup-API-Sample    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.create:
            createTestFiles();
            break;
        case R.id.restore:
            new BackupManager(this).requestRestore(new RestoreObserver() {
                @Override
                public void restoreFinished(int error) {
                    if (error == 0) {
                        Toast.makeText(MainActivity.this, R.string.files_restored, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(MainActivity.this, getString(R.string.restore_failed, error), Toast.LENGTH_SHORT).show();
                    }
                }
            });
            break;
    }

    return super.onOptionsItemSelected(item);
}
项目:novelty    文件:DbProvider.java   
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    SQLiteDatabase dbWritable = mOpenHelper.getWritableDatabase();

    dbWritable.beginTransaction();

    int count = dbWritable.update(getTableName(uri), values, selection, selectionArgs);

    dbWritable.setTransactionSuccessful();
    dbWritable.endTransaction();

    // Log.i(TAG, "Updated rows: " + count);
    if (count > 0) {
        BackupManager.dataChanged(getContext().getPackageName());
    }
    return count;
}
项目:novelty    文件:BaseActivity.java   
/**
 * {@inheritDoc}
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
    sharedPrefs.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            BackupManager.dataChanged(getPackageName());
        }
    });

    Utils.setStrictMode(true);

    setContentView(getLayoutResource());
    initUI();
}
项目:Advanced-Settings-for-Android-Wear    文件:MainActivity.java   
/**
 * Requests the system to update the system locale. Note that the system looks halted
 * for a while during the Locale migration, so the caller need to take care of it.
 * <p/>
 * Requires android.permission.CHANGE_CONFIGURATION
 */
public static void updateLocale(Locale locale) {
    try {
        IActivityManager am = ActivityManagerNative.getDefault();

        Configuration config = am.getConfiguration();

        // Will set userSetLocale to indicate this isn't some passing default - the user
        // wants this remembered
        config.setLocale(locale);

        am.updateConfiguration(config);
        // Trigger the dirty bit for the Settings Provider.
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException e) {
        // Intentionally left blank
    }
}
项目:Noyze    文件:ConfigurationActivity.java   
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    LOGI(TAG, "onSharedPreferenceChanged(" + key + ')');
    Context context = getApplicationContext();
    if (null != context) {
        (new BackupManager(context)).dataChanged();
    }

    if (Constants.PREF_VOLUME_PANEL.equals(key)) {
        // TRACK: what theme is being used.
        String panel = sharedPreferences.getString(key, StatusBarVolumePanel.TAG);
        VolumeAccessibilityService.VolumePanelChangeEvent event =
                new VolumeAccessibilityService.VolumePanelChangeEvent(panel, Utils.supportsMediaPlayback(panel));
        onVolumePanelChangeEvent(event);
    } else if (Constants.PREF_REPORTING.equals(key)) {
        // TRACK: when the user opts out of being tracked.
    }
}
项目:geoPingProject    文件:GeoPingPrefActivity.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    // Ask Backup
    BackupManager.dataChanged(getPackageName());
    // Recompute Change Sumaries
    Log.d(TAG, "### onSharedPreferenceChanged key : " + key);
     Preference pref = findPreference(key);
    Log.d(TAG, "### onSharedPreferenceChanged findPreference : " + pref);
    setSummary(this, pref);
    // Tracker
    // GeoPingApplication.getInstance().tracker().trackPageView("/Pref/" +
    // key);
    Tracker tracker = tracker = GeoPingApplication.getGeoPingApplication(this).getTracker();
    tracker.send(new HitBuilders.EventBuilder()//
            .setCategory("ui_pref") // Category
            .setAction("changed") // Action
            .setLabel(key) // Label
            .build());
}
项目:geoPingProject    文件:GeoPingPrefActivity.java   
/**
 * Click handler, designated in the layout, that runs a restore of the app's
 * most recent data when the button is pressed.
 */
public void onRestoreButtonClick(View v) {
    Log.v(TAG, "Requesting restore of our most recent data");
    BackupManager mBackupManager = new BackupManager(this);
    mBackupManager.requestRestore(new RestoreObserver() {
        public void restoreFinished(int error) {
            /** Done with the restore! Now draw the new state of our data */
            if (error == 0) {
                Log.v(TAG, "Restore finished, error = " + error);
                NotifToasts.showBackupRestored(GeoPingPrefActivity.this);
            } else {
                Log.e(TAG, "Restore finished with error = " + error);
            }
        }
    });
}
项目:geoPingProject    文件:PersonProvider.java   
@Override
public Uri insert(Uri uri, ContentValues values) {
    switch (sURIMatcher.match(uri)) {
    case PERSONS:
        long personId = personDatabase.insertEntity(values);
        Uri personUri = null;
        if (personId > -1) {
            personUri = Uri.withAppendedPath(Constants.CONTENT_URI, String.valueOf(personId));
            getContext().getContentResolver().notifyChange(uri, null);
            // Backup
            BackupManager.dataChanged(getContext().getPackageName());
        }
        return personUri;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
}
项目:geoPingProject    文件:PersonProvider.java   
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    int count = 0;
    switch (sURIMatcher.match(uri)) {
    case PERSON_ID:
        String entityId = uri.getLastPathSegment();
        String[] args = new String[] { entityId };
        count = personDatabase.deleteEntity(PersonColumns.SELECT_BY_ENTITY_ID, args);
        break;
    case PERSONS:
        count = personDatabase.deleteEntity(selection, selectionArgs);
        break;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
    if (count > 0) {
        getContext().getContentResolver().notifyChange(uri, null);
        // Backup
       BackupManager.dataChanged(getContext().getPackageName());
     }
    return count;
}
项目:geoPingProject    文件:PersonProvider.java   
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    int count = 0;
    switch (sURIMatcher.match(uri)) {
    case PERSON_ID:
        String entityId = uri.getLastPathSegment();
        String[] args = new String[] { entityId };
        count = personDatabase.updateEntity(values, PersonColumns.SELECT_BY_ENTITY_ID, args);
        break;
    case PERSONS:
        count = personDatabase.updateEntity(values, selection, selectionArgs);
        break;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
    if (count > 0) {
        getContext().getContentResolver().notifyChange(uri, null);
        // Backup
        BackupManager.dataChanged(getContext().getPackageName());
    }
    return count;
}
项目:geoPingProject    文件:PairingProvider.java   
@Override
public Uri insert(Uri uri, ContentValues values) {
    switch (sURIMatcher.match(uri)) {
    case PAIRINGS:

        long pairingId = pairingDatabase.insertEntity(values);
        Uri pairingUri = null;
        if (pairingId > -1) {
            pairingUri = Uri.withAppendedPath(Constants.CONTENT_URI, String.valueOf(pairingId));
            getContext().getContentResolver().notifyChange(uri, null);
            Log.i(TAG, String.format("Insert Pairing %s : %s", pairingUri, values));
            // Backup
            BackupManager.dataChanged(getContext().getPackageName());
        }
        return pairingUri;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
}
项目:geoPingProject    文件:PairingProvider.java   
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    int count = 0;
    switch (sURIMatcher.match(uri)) {
    case PAIRING_ID:
        String entityId = uri.getLastPathSegment();
        String[] args = new String[] { entityId };
        count = pairingDatabase.deleteEntity(PairingColumns.SELECT_BY_ENTITY_ID, args);
        break;
    case PAIRINGS:
        count = pairingDatabase.deleteEntity(selection, selectionArgs);
        break;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
    if (count > 0) {
        getContext().getContentResolver().notifyChange(uri, null);
        // Backup
       BackupManager.dataChanged(getContext().getPackageName());
    }
    return count;
}
项目:geoPingProject    文件:PairingProvider.java   
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    int count = 0;
    switch (sURIMatcher.match(uri)) {
    case PAIRING_ID:
        String entityId = uri.getLastPathSegment();
        String[] args = new String[] { entityId };
        count = pairingDatabase.updateEntity(values, PairingColumns.SELECT_BY_ENTITY_ID, args);
        break;
    case PAIRINGS:
        count = pairingDatabase.updateEntity(values, selection, selectionArgs);
        break;
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }
    if (count > 0) {
        getContext().getContentResolver().notifyChange(uri, null);
        // Backup
       BackupManager.dataChanged(getContext().getPackageName());
    }
    return count;
}
项目:geoPingProject    文件:GeoFenceProvider.java   
@Override
public Uri insert(Uri uri, ContentValues values) {
    switch (sURIMatcher.match(uri)) {
        case GEOFENCES:
            long geofenceId = geofenceDatabase.insertEntity(values);
            Uri geofenceUri = null;
            if (geofenceId > -1) {
                geofenceUri = Constants.getContentUri(geofenceId);
                getContext().getContentResolver().notifyChange(uri, null);
                Log.i(TAG, String.format("Insert GeoFence %s : %s", geofenceUri, values));
                // Backup
                BackupManager.dataChanged(getContext().getPackageName());
            }
            return geofenceUri;
        default:
            throw new IllegalArgumentException("Unknown insert Uri: " + uri);
    }
}
项目:geoPingProject    文件:GeoFenceProvider.java   
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    int count = 0;
    switch (sURIMatcher.match(uri)) {
        case GEOFENCE_ID:
            String entityId = uri.getLastPathSegment();
            String[] args = new String[]{entityId};
            count = geofenceDatabase.updateEntity(values, GeoFenceColumns.SELECT_BY_ENTITY_ID, args);
            break;
        case GEOFENCES:
            count = geofenceDatabase.updateEntity(values, selection, selectionArgs);
            break;
        default:
            throw new IllegalArgumentException("Unknown update Uri: " + uri);
    }
    if (count > 0) {
        getContext().getContentResolver().notifyChange(uri, null);
        // Backup
        BackupManager.dataChanged(getContext().getPackageName());
    }
    return count;
}
项目:Calendar_lunar    文件:GeneralPreferences.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
        String key) {
    Activity a = getActivity();
    if (key.equals(KEY_ALERTS)) {
        updateChildPreferences();
        if (a != null) {
            Intent intent = new Intent();
            intent.setClass(a, AlertReceiver.class);
            if (mAlert.isChecked()) {
                intent.setAction(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS);
            } else {
                intent.setAction(CalendarContract.ACTION_EVENT_REMINDER);
            }
            a.sendBroadcast(intent);
        }
    }
    if (a != null) {
        BackupManager.dataChanged(a.getPackageName());
    }
}
项目:Dash    文件:ExtensionManager.java   
private void saveActiveExtensionList() {
    StringBuilder sb = new StringBuilder();

    synchronized (mActiveExtensions) {
        for (ExtensionWithData ci : mActiveExtensions) {
            if (sb.length() > 0) {
                sb.append(",");
            }
            sb.append(ci.listing.componentName.flattenToString());
        }
    }

    mDefaultPreferences.edit()
            .putString(PREF_ACTIVE_EXTENSIONS, sb.toString())
            .commit();
    new BackupManager(mApplicationContext).dataChanged();
}
项目:Dash    文件:ConfigureAdvancedFragment.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
    new BackupManager(getActivity()).dataChanged();

    // Potentially enable/disable the launcher activity if the settings button
    // preference has changed.
    if (isAdded() && AppearanceConfig.PREF_SETTINGS_BUTTON.equals(key)) {
        boolean enableLauncher = AppearanceConfig.PREF_SETTINGS_BUTTON_IN_LAUNCHER.equals(
                sp.getString(AppearanceConfig.PREF_SETTINGS_BUTTON, null));
        getActivity().getPackageManager().setComponentEnabledSetting(
                new ComponentName(
                        getActivity().getPackageName(),
                        ConfigurationActivity.LAUNCHER_ACTIVITY_NAME),
                enableLauncher
                        ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}
项目:android-kioskime    文件:SettingsFragment.java   
@Override
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
    (new BackupManager(getActivity())).dataChanged();
    final Resources res = getResources();
    if (key.equals(Settings.PREF_POPUP_ON)) {
        setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
                Settings.readKeyPreviewPopupEnabled(prefs, res));
    } else if (key.equals(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY)) {
        setPreferenceEnabled(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST,
                Settings.readShowsLanguageSwitchKey(prefs));
    } else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) {
        LauncherIconVisibilityManager.updateSetupWizardIconVisibility(getActivity());
    }
    ensureConsistencyOfAutoCorrectionSettings();
    updateVoiceModeSummary();
    updateShowCorrectionSuggestionsSummary();
    updateKeyPreviewPopupDelaySummary();
    refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, getResources());
}
项目:CineTime    文件:DBHelper.java   
/**
 * Insert new item into favorites
 *
 * @param context
 */
@SuppressLint("NewApi")
public static void insertFavorite(Context context, String code, String title, String location) {
    synchronized (DBHelper.sDataLock) {
        SQLiteDatabase db = getDatabase(context);

        ContentValues values = new ContentValues();
        values.put("code", code);
        values.put("title", title);
        values.put("location", location);
        db.insert("favorites", null, values);
        db.close();
    }
    favCodes.add(code);
    new BackupManager(context).dataChanged();
}