giozh
giozh

Reputation: 10078

Save pictures into different folder

I have this code for take picture from my app, then save into different directory than default:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    directory_path = "/tempCamera";
    directory = new File(Environment.getExternalStorageDirectory(),
            directory_path);
    if (!directory.exists()) {
        directory.mkdirs();

    }

    camera_button = (Button) findViewById(R.id.camera_button);
    camera_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent camera_intent = new Intent(
                    MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);

            camera_intent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(directory));
            MainActivity.this.startActivityForResult(camera_intent, 0);

        }

    });
}

but pictures is always saved into default directory. What's wrong?

Upvotes: 0

Views: 113

Answers (1)

Beloo
Beloo

Reputation: 9925

You should pass to the MediaStore.EXTRA_OUTPUT, not a path to folder, but a path to a result image.

Upvotes: 3

Related Questions