Reputation: 2348
I am experimenting with the Camera on my non-rooted 4.0.4 Android device having no sd-card. I am doing some burst-shots and saving them on the internal memory.
My problem is that my photos get stored in /data/data/my.package.name/files
which I cannot access without root-permission. I can see the files, but they have no read-permission.
I found some broadcast-Intent that should make them visible in the standard-gallery, but that doesn't seem to work neither.
Does anyone have another idea of how I can access my photos? Or tweak the stuff I tried so far?
how I save the photos:
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
try {
Log.i(TAG, ""+Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES));
Log.i(TAG,"fotofolder is "+getFilesDir());
// write to local sandbox file system
outStream = CameraDemo.this.openFileOutput(String.format("%d.jpg",
System.currentTimeMillis()), 0);
outStream.write(data);
outStream.close();
//this intent should make fotos visible in the gallery
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.fromFile(Environment.getExternalStorageDirectory())));
// Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Log.i(TAG, "onPictureTaken - wrote bytes: " + data.length);
...
}
the log:
08-23 12:42:49.324: I/FrontCamera(15832): /mnt/sdcard/Pictures
08-23 12:42:49.327: I/FrontCamera(15832): fotofolder is /data/data/com.example.camera/files
08-23 12:42:49.370: I/FrontCamera(15832): onPictureTaken - wrote bytes: 430493
<--- it puts the photos to the data/data...
folder, instead of the useful mnt/sdcard/Pictures
Upvotes: 1
Views: 6938
Reputation: 28484
To reflect image in gallery try this:
MediaScannerConnection.scanFile(DetailsActivity.this, new String[] {filepath }, null, new OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
}
});
Upvotes: 1
Reputation: 18712
MediaStore.Images.Media.insertImage(getContentResolver(), imageBitmap, imageTitle, imageDescription);
you can use the internal storage for saving.
Upvotes: 1