So, I'm trying to save a mp4 file from a temp file to the picture directory. The tablet works fine. But it's not working on a samsung nexus. It's not even creating the directory.
private void moveFileToGallery() {
File mediaStorageDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
VIDEO_DIRECTORY_NAME);
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.d(VIDEO_DIRECTORY_NAME, ": Failed to create directory");
return;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
.format(new Date());
String videoFileName = "VID_"+timeStamp+".mp4";
File source= new File("/sdcard/myvideo.mp4");
File destination= new File(mediaStorageDir.getPath() + "/"+videoFileName);
source.renameTo(destination);
Toast.makeText(getApplicationContext(), "Video Saved to Gallery!", Toast.LENGTH_LONG).show();
}
}
Anyone know what's wrong with my code?