Reputation: 1127
I am able create and start an intent to capture a video. But how can I set the file name and save it to a specific directory?
Here's what I have so far:
videoPath = "/X1," + num1 +
",Y1," + num2 +
",X2," + num3 +
",Y2," + num4 +
",A," + num5 +
",G," + num6 +
",la," + num7 +
",lo," + num8+ ".mp4";
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoPath);
startActivityForResult(intent, VIDEO_INTENT);
Upvotes: 0
Views: 740
Reputation: 1006724
But how can I set the file name and save it to a specific directory?
You are setting the filename. It is most of what you have in videoPath
.
However:
Your videoPath
does not specify a directory, other than an invalid leading slash. Use getExternalFilesDir()
on Context
to get a likely File
object for the directory, then create a new File
object pointing to the actual file you want to use.
I am not sure if commas will work well in filenames here.
EXTRA_OUTPUT
is a Uri
, not a String
or a File
. Use Uri.fromFile()
to convert your File
to a Uri
.
Upvotes: 1