Code example for BackupDataOutput

Methods: writeEntityData, writeEntityHeader

0
        outWriter.writeUTF(mode);
        outWriter.writeLong(carID);
        // Send the data to the Backup Manager via the BackupDataOutput 
        byte[] buffer = bufStream.toByteArray();
        int len = buffer.length;
        data.writeEntityHeader(PREFS_HEADER, len);
        data.writeEntityData(buffer, len);
        bufStream.close();
        outWriter.close();
        } catch (IOException e) {
            Util.Error("MPGBackupAgent", "Error saving preferences: " + e.getMessage());
        } 
    } 
 
    private void doBackup( BackupDataOutput data, ParcelFileDescriptor newState) {
 
        DBHelper helper = new DBHelper(this);
        SQLiteDatabase db = helper.getReadableDatabase();
 
        // SELECT * FROM cars; used String[] for column names to know the column index 
        Cursor q = db.query("cars",new String[] {"id","make","model","year","miles","icon"},null,null,null,null,null);