Android saving images <p>this application i'm working on is suppose to allow a user to take a photo, depending on whether the GPS is enabled or not, the image should be saved into 2 different folders. However, i can't seem to change the directory.</p> <pre><code> camIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss"); String date = dateFormat.format(new Date()); photoFile = "Picture_" + date + ".jpg"; fileName = pictureDir.getPath() + File.separator + photoFile; pictureFile = new File(fileName); Uri outputFileUri = Uri.fromFile(pictureFile); camIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(camIntent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); </code></pre> <p>and in my onActivityResult</p> <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { if (GPSValid == 0) { pictureDir = new File(Environment .getExternalStorageDirectory().toString() + File.separator + "cameraDemoValid"); } else if (GPSValid == 1) { pictureDir = new File(Environment .getExternalStorageDirectory().toString() + File.separator + "cameraDemoInvalid"); } fileName = pictureDir.getPath() + File.separator + photoFile; pictureFile = new File(fileName); Uri outputFileUri = Uri.fromFile(pictureFile); camIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); </code></pre> <p>However, when i do this, i get a "can't write back - not read at all" error and the image is not saved and if i did include the "camIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);" in onActivityResult(), it works. Am i on the right track?</p>