So I'm using an image capture library that gives me a URI to a temporary cached file. I want to then save that file in my app's file directory as "/avatar.jpg", overwriting any existing "avatar.jpg" file. So far, this is my code for attempting to accomplish my goal:
File file = new File(tempImagePath);
File avatarFile = new File(getFilesDir(), "avatar.jpg");
file.renameTo(avatarFile);
However, this does not overwrite any existing "avatar.jpg" file. I've noticed several changes to the filesystem API such as the introduction of FileProvider so I'm not what the fastest/most efficient way of accomplishing what I require is.