From 1cf587496fcb1d652bab9fc6792fb106b6fefaa4 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Fri, 12 Jun 2009 11:06:24 -0700 Subject: Add RestoreFileHelper, BackupDataInput, and add java wrappers for the methods on BackupDataOutput. --- core/java/android/backup/FileBackupHelper.java | 43 +++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'core/java/android/backup/FileBackupHelper.java') diff --git a/core/java/android/backup/FileBackupHelper.java b/core/java/android/backup/FileBackupHelper.java index 99051bf82f9e..ed840bb3ffba 100644 --- a/core/java/android/backup/FileBackupHelper.java +++ b/core/java/android/backup/FileBackupHelper.java @@ -27,21 +27,56 @@ import java.io.FileDescriptor; public class FileBackupHelper { private static final String TAG = "FileBackupHelper"; + Context mContext; + String mKeyPrefix; + + public FileBackupHelper(Context context) { + mContext = context; + } + + public FileBackupHelper(Context context, String keyPrefix) { + mContext = context; + mKeyPrefix = keyPrefix; + } + /** * Based on oldState, determine which of the files from the application's data directory * need to be backed up, write them to the data stream, and fill in newState with the * state as it exists now. */ - public static void performBackup(Context context, - ParcelFileDescriptor oldState, BackupDataOutput data, + public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState, String[] files) { - File base = context.getFilesDir(); + // file names + File base = mContext.getFilesDir(); final int N = files.length; String[] fullPaths = new String[N]; for (int i=0; ioriginal; + * otherwise, return original. + */ + static String[] makeKeys(String keyPrefix, String[] original) { + if (keyPrefix != null) { + String[] keys; + final int N = original.length; + keys = new String[N]; + for (int i=0; i