I am currently writing my first Android app. I feel quite at home in Java, but here's one thing which puzzles me. I have written a small Activity which lets you import/export contacts. And I want the photos to be transported as well. To store the photos, I save them into the text file as Base64 encoded strings. I decode this string to store the photo in the restored contacts. I don't update the contacts however, but I recreate them (delete them all, and then recreate the from the dump file). It all works pretty well except the restoration of the photo. There's no error, no exception, but the photo remains empty. Here's what I do:
A few details may be of interest:
- This runs in a separate thread. When instantiating the thread, I pass a reference to the calling class (the Activity). The variable "cr" comes from "caller.getContentResolver()"
- The IOException is never thrown (AFAICT)
- I am using a third party Base64 class. But it works fine. I tried to use an encoded string on a laptop, decoded it with python and stored the result as JPEG image. The resulting file was correct.
- I read the Android source of the method "setPhotoData" and tried to work from there without any luck.
Apparently this works for other people. So there must be something I am missing. Does anyone have any idea as to where I could look?