Finally with this code i can obtain file. Pick the uri of the video and copy the video with the name you want to the folder
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.i("CODES", "" + requestCode + ", " + resultCode + ", " + data);
if (requestCode == RESULT_VIDEO_REALIZADO && resultCode == RESULT_OK) {
String filePath = null;
Uri _uri = data.getData();
Log.d("", "URI = " + _uri);
if (_uri != null && "content".equals(_uri.getScheme())) {
Cursor cursor = this
.getContentResolver()
.query(_uri,
new String[] { android.provider.MediaStore.Video.VideoColumns.DATA },
null, null, null);
cursor.moveToFirst();
filePath = cursor.getString(0);
cursor.close();
} else {
filePath = _uri.getPath();
}
Log.d("", "Chosen path = " + filePath);
if (!file.exists()) {
copyFile(filePath, file.toString());
Log.i("COPY", "Copy: " + videoUri.toString() + " a "
+ file.toString());
}
Log.i("uriVid", videoUri.getPath());
}
private void copyFile(String inputFile, String outputFile) {
InputStream in = null;
OutputStream out = null;
try {
// create output directory if it doesn't exist
File dir = new File(folder.toString());
if (!dir.exists()) {
dir.mkdirs();
}
in = new FileInputStream(inputFile);
out = new FileOutputStream(outputFile);
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
in = null;
// write the output file (You have now copied the file)
out.flush();
out.close();
out = null;
} catch (FileNotFoundException fnfe1) {
Log.e("tag", fnfe1.getMessage());
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
}