'How to Move or Rename Image, Video File in Android 11 in Scoped Storage in Android Studio
i want to move and rename image file and this image file is not created my app so can i move or rename image file in android 11 in scoped storage.
this is rename method for android api 11.
but it didn't work.
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "newFolder");
if (!dir.exists()) {
dir.mkdir();
}
File file = new File(model.getPicturePath());
long mediaID = getFilePathToMediaID(new File(file.getAbsolutePath()).getAbsolutePath(), this);
Uri utiOne =ContentUris.withAppendedId(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL),mediaID);
String path = dir.getAbsolutePath()+File.separator+model.getPictureName();
Toast.makeText(this, "" +model.getPicturePath(), Toast.LENGTH_SHORT).show();
ContentValues cv = new ContentValues();
// cv.put(MediaStore.Images.Media.BUCKET_DISPLAY_NAME,".newFolder");
// cv.put(MediaStore.Images.Media.RELATIVE_PATH,Environment.DIRECTORY_PICTURES+File.separator+".newFolder");
cv.put(MediaStore.Images.Media.DATA,path);
// cv.put(MediaStore.Images.Media._ID,model.getPictureId());
getContentResolver().update(utiOne,cv,null);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
