Code example for BackupDataOutput

Methods: writeEntityData, writeEntityHeader

0
        writeStateFile(mAllPackages, newState);
    } 
     
    private static void writeEntity(BackupDataOutput data, String key, byte[] bytes)
            throws IOException { 
        data.writeEntityHeader(key, bytes.length);
        data.writeEntityData(bytes, bytes.length);
    } 
 
    // "Restore" here is a misnomer.  What we're really doing is reading back the 
    // set of app signatures associated with each backed-up app in this restore 
    // image.  We'll use those later to determine what we can legitimately restore. 
    public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
            throws IOException { 
        List<ApplicationInfo> restoredApps = new ArrayList<ApplicationInfo>();
        HashMap<String, Metadata> sigMap = new HashMap<String, Metadata>();
        if (DEBUG) Slog.v(TAG, "onRestore()");
        int storedSystemVersion = -1;
 
        while (data.readNextHeader()) {
            String key = data.getKey();