Java Code Examples for android.app.backup.BackupDataOutput#writeEntityData()
The following examples show how to use
android.app.backup.BackupDataOutput#writeEntityData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
private long writeIfChanged(long oldChecksum, String key, byte[] data, BackupDataOutput output) { CRC32 checkSummer = new CRC32(); checkSummer.update(data); long newChecksum = checkSummer.getValue(); if (oldChecksum == newChecksum) { return oldChecksum; } try { output.writeEntityHeader(key, data.length); output.writeEntityData(data, data.length); } catch (IOException ioe) { // Bail } return newChecksum; }
Example 2
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
private long writeIfChanged(long oldChecksum, String key, byte[] data, BackupDataOutput output) { CRC32 checkSummer = new CRC32(); checkSummer.update(data); long newChecksum = checkSummer.getValue(); if (oldChecksum == newChecksum) { return oldChecksum; } try { if (DEBUG_BACKUP) { Log.v(TAG, "Writing entity " + key + " of size " + data.length); } output.writeEntityHeader(key, data.length); output.writeEntityData(data, data.length); } catch (IOException ioe) { // Bail } return newChecksum; }
Example 3
Source File: LauncherBackupHelper.java From TurboLauncher with Apache License 2.0 | 6 votes |
private void writeRowToBackup(Key key, byte[] blob, Journal out, BackupDataOutput data) throws IOException { String backupKey = keyToBackupKey(key); data.writeEntityHeader(backupKey, blob.length); data.writeEntityData(blob, blob.length); out.rows++; out.bytes += blob.length; if (VERBOSE) Log.v(TAG, "saving " + geKeyType(key) + " " + backupKey + ": " + getKeyName(key) + "/" + blob.length); if(DEBUG_PAYLOAD) { String encoded = Base64.encodeToString(blob, 0, blob.length, Base64.NO_WRAP); final int chunkSize = 1024; for (int offset = 0; offset < encoded.length(); offset += chunkSize) { int end = offset + chunkSize; end = Math.min(end, encoded.length()); Log.w(TAG, "wrote " + encoded.substring(offset, end)); } } }
Example 4
Source File: SipProfilesHelper.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
private void writeData(BackupDataOutput data, String value) throws IOException { // Create buffer stream and data output stream for our data ByteArrayOutputStream bufStream = new ByteArrayOutputStream(); DataOutputStream outWriter = new DataOutputStream(bufStream); // Write structured data outWriter.writeUTF(value); // Send the data to the Backup Manager via the BackupDataOutput byte[] buffer = bufStream.toByteArray(); int len = buffer.length; data.writeEntityHeader(ACCOUNTS_BACKUP_KEY, len); data.writeEntityData(buffer, len); }
Example 5
Source File: SipSharedPreferencesHelper.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
private void writeData(BackupDataOutput data, String value) throws IOException { // Create buffer stream and data output stream for our data ByteArrayOutputStream bufStream = new ByteArrayOutputStream(); DataOutputStream outWriter = new DataOutputStream(bufStream); // Write structured data outWriter.writeUTF(value); // Send the data to the Backup Manager via the BackupDataOutput byte[] buffer = bufStream.toByteArray(); int len = buffer.length; data.writeEntityHeader(SETTINGS_BACKUP_KEY, len); data.writeEntityData(buffer, len); }
Example 6
Source File: MyTracksBackupAgent.java From mytracks with Apache License 2.0 | 5 votes |
private void backupPreferences(BackupDataOutput data, SharedPreferences preferences) throws IOException { PreferenceBackupHelper preferenceDumper = createPreferenceBackupHelper(); byte[] dumpedContents = preferenceDumper.exportPreferences(preferences); data.writeEntityHeader(PREFERENCES_ENTITY, dumpedContents.length); data.writeEntityData(dumpedContents, dumpedContents.length); }
Example 7
Source File: LauncherBackupHelper.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
private void writeRowToBackup(String backupKey, MessageNano proto, BackupDataOutput data) throws IOException { byte[] blob = writeCheckedBytes(proto); data.writeEntityHeader(backupKey, blob.length); data.writeEntityData(blob, blob.length); mBackupDataWasUpdated = true; if (VERBOSE) Log.v(TAG, "Writing New entry " + backupKey); }
Example 8
Source File: LauncherBackupHelper.java From LB-Launcher with Apache License 2.0 | 5 votes |
private void writeRowToBackup(String backupKey, MessageNano proto, BackupDataOutput data) throws IOException { byte[] blob = writeCheckedBytes(proto); data.writeEntityHeader(backupKey, blob.length); data.writeEntityData(blob, blob.length); if (VERBOSE) Log.v(TAG, "Writing New entry " + backupKey); }