0

When I use android/com.android.internal.backup.LocalTransport I have no problems to store images (byte[]) along with other text data.

When I try to uninstall and install dev app on a device I see blank images and the following error SkImageDecoder::Factory returned null error

The way I store an image file in JSON:

File file = new File(filesDir, pictureFilename);
jsonObject.put("pictureFile", file.toString().getBytes());

And that's how I restore them:

try {
    FileOutputStream out = new FileOutputStream(file);
    out.write(jsonObject.get("pictureFile").toString().getBytes());
    out.close();
} catch (Exception e) {
    Log.e(TAG, "Can not write pictureFile", e);
}

UPD. My BackupAgent

Dmitry
  • 1,484
  • 2
  • 15
  • 23
  • When working with images, chances are that, if you are receiving errors, might be due to OutOfMemoryErrors. Search in you stack trace for something like that...look here if that is the case: http://stackoverflow.com/questions/29430640/outofmemoryerror-while-decoding-and-encoding-base64-string-into-bitmap – Fustigador Feb 11 '16 at 08:11
  • I don't have `OutOfMemoryError`s and I don't decode Base64 strings into Bitmaps. – Dmitry Feb 11 '16 at 08:19

0 Answers0