android.app.backup.BackupDataOutput#writeEntityData ( )源码实例Demo

下面列出了android.app.backup.BackupDataOutput#writeEntityData ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Study_Android_Demo   文件: SettingsBackupAgent.java
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;
}
 
源代码2 项目: Study_Android_Demo   文件: SettingsBackupAgent.java
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;
}
 
源代码3 项目: TurboLauncher   文件: LauncherBackupHelper.java
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));
        }
    }
}
 
源代码4 项目: CSipSimple   文件: SipProfilesHelper.java
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);
}
 
源代码5 项目: CSipSimple   文件: SipSharedPreferencesHelper.java
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);
}
 
源代码6 项目: mytracks   文件: MyTracksBackupAgent.java
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);
}
 
源代码7 项目: Trebuchet   文件: LauncherBackupHelper.java
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);
}
 
源代码8 项目: LB-Launcher   文件: LauncherBackupHelper.java
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);
}
 
 同类方法