I would like some help with saving pictures taken from my camera to a specific folder on the SD card. My camera opens up, takes the photos, and saves them; but it saves them to the standard folder. The code I have so for is:
public class Camera extends Activity {
public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;
private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
String Path;
private Uri fileUri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras=getIntent().getExtras();
Path= extras.getString("Path");
Log.d("camear","path: "+Path);
//File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyCameraApp");
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
this.startActivity(intent);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
//mediaFile = new File(mediaStorageDir.getPath() + File.separator +"IMG_"+ timeStamp + ".jpg");
//fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
Uri outputFileUri= Uri.fromFile(new File(Path+"/camera/"+timeStamp+".jpg"));// create a file to save the image
intent.putExtra("output", outputFileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
The path is coming from another activity on the application, and it passes its values fine. In the previous activity, it creates the folders that I want to save the pictures into.
I have looked at the following answer, and tried to implement some of the suggestions: How to save images from Camera in Android to specific folder?. One thing I didnt try, was in the last suggestion on the OnActivityResult. Is that the key or is there somthing else I am missing? This page here mentions the ContentResolver The Camera Intent is simply not working, one thing is that both pages look like they want to do the same, but go about it in different ways.