Android BackupDataInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android BackupDataInputStream class.

This code example shows how to use the following methods:getKey, read, size
     * @see android.app.backup.BackupHelper#restoreEntity(android.app.backup. 
     * BackupDataInputStream) 
     */ 
    @Override 
    public void restoreEntity(BackupDataInputStream data) {
        if (ACCOUNTS_BACKUP_KEY.equalsIgnoreCase(data.getKey())) {
            try { 
                String profilesStr = readData(data);
                JSONArray accounts = new JSONArray(profilesStr);
                if (accounts != null && accounts.length() > 0) {
                    SipProfileJson.restoreSipAccounts(mContext, accounts);
                } 
            } catch (IOException e) {
                Log.e(THIS_FILE, "Cannot restore backup entry", e);
            } catch (JSONException e) {
                Log.e(THIS_FILE, "Cannot parse backup entry", e);
            } 
        } 
    } 
 

5
CodeRank
This code example shows how to use the following methods:read, size
     * @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;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, size
    /** 
     * 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, "-------------------------------------------------");
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, size
    /** 
     * 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, "-------------------------------------------------");
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, size
    /** 
     * 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, "-------------------------------------------------");
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, size
    // Restore 
    // =========================================================== 
 
    @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, "-------------------------------------------------");
    } 
 
    public void readBackup(InputStream data) {
        Log.d(TAG, "read Backup : " + data);
        try { 
            JsonFactory f = new JsonFactory();
4
CodeRank
See Code Examples for Android BackupDataInputStream Methods: