Man, I am still not able to save a picture when I send an intent asking for a photo to be taken. Here\'s what I am doing:
Make a URI representing
Your problem might be with the directory you're trying to store the file in. To save files to the SD card you don't need any special permissions, but the way you get the folder reference is different to how you've done it. It also depends on whether you want to save the image in a way that can be retrieved by the MediaStore (i.e. things like the gallery or albums application, or any other app that relies on those to find images) or not. Assuming you want it to be listed in the MediaStore, here's the code to do that:
ContentValues newImage = new ContentValues(2);
newImage.put(Media.DISPLAY_NAME, "whatever name you want shown");
newImage.put(Media.MIME_TYPE, "image/png");
Uri uri = contentResolver.insert(Media.EXTERNAL_CONTENT_URI, newImage);
try {
Bitmap bitmap = //get your bitmap from the Camera, however that's done
OutputStream out = contentResolver.openOutputStream(uri);
boolean success = bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.close();
if (success){
Log.d("Image Writer", "Image written successfully.");
} else {
Log.d("Image Writer", "Image write failed, but without an explanation.");
}
} catch (Exception e){
Log.d("Image Writer", "Problem with the image. Stacktrace: ", e);
}
On my emulator running v1.5, that's successfully saves a bitmap onto the SD card in the DCIM/Camera folder with its file name being current time. (The time is saved in milliseconds since 1st Jan 1970, also known as the "Epoch" for some reason.)