I am using a button to pick videos from device like
dStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("video/*");
startActivityForResult(photoPickerIntent, SELECT_VIDEO);
}
});
Then in the onActivityResult
I have something like this
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case SELECT_VIDEO:
if (resultCode == RESULT_OK) {
Uri selectedVideo = data.getData();
final String realPath = selectedVideo.getPath();
}
break;
}
}
The realPath
which I need is the location to the file in the device like /directory/subdirectory/myVideo.mp4
. I have tried a lot of posts previously from stackoverflow
itself. All results lead to the value of realPath
as null
. The posts which I tried are
- GetRealPathFromUri always get null result
- Get filename and path from uri from mediastore
- Get Real Path For Uri Android
So if you know any way that works, suggest me below. Dont mark as duplicate and other stuff. I know nothing is working.