@Override public void restoreEntity(final BackupDataInputStream data) { final DAO dao = new DAO(context); if (KEY.equals(data.getKey())) { final BufferedReader reader = new BufferedReader(new InputStreamReader(data)); try { dao.restoreFromReader(reader); } catch (IOException e) { e.printStackTrace(); } } dao.close(); }
/** * Read data from the input stream * * @param data the input stream * @return the data * @throws IOException I/O error */ private String readData(BackupDataInputStream data) throws IOException { String dataS; byte[] buf = new byte[data.size()]; data.read(buf, 0, buf.length); ByteArrayInputStream bais = new ByteArrayInputStream(buf); DataInputStream dis = new DataInputStream(bais); dataS = dis.readUTF(); dis.close(); bais.close(); return dataS; }
/** * Restores one entity from the restore data stream to its proper shared * preferences file store. */ public void restoreEntity(BackupDataInputStream data) { String key = data.getKey(); Log.i(TAG, "-------------------------------------------------"); Log.i(TAG, "--- restore Entity '" + key + "' size=" + data.size()); super.restoreEntity(data); Log.i(TAG, "----- restoreEntity End"); Log.i(TAG, "-------------------------------------------------"); }
@Override public void restoreEntity(BackupDataInputStream data) { String key = data.getKey(); Log.i(TAG, "-------------------------------------------------"); Log.i(TAG, "--- restore Entity '" + key + "' size=" + data.size()); if (backupKey.equals(key)) { readBackup(data); } Log.i(TAG, "----- restoreEntity End"); Log.i(TAG, "-------------------------------------------------"); }
@Override public void restoreEntity(BackupDataInputStream data) { byte[] buf = new byte[data.size()]; try { data.read(buf); ContentValues values = mAdaptor.Unserialise(buf); mContext.getContentResolver().insert(mUri, values); } catch (IOException e) { Log.e("AltidroidBackup", "Unable to read backup value: " + data.getKey()); e.printStackTrace(); } }
@Override public void restoreEntity(BackupDataInputStream data) { if (mRestoreEnabled) { super.restoreEntity(data); } }
@Override public void restoreEntity(BackupDataInputStream data) { stopContentProvider(); super.restoreEntity(data); }