I am working on a gallery kind of application.
Here, I am using view pager to display images which are stored in internal memory, and I have five bottom navigation menus.
Now what I want to do this is to rotate the image on rotate menu click and save the rotated bitmap to it existing path.
I have searched a lot but no luck.
On menu click :
new AsyncTask<Void,Void,Void>(){
    @Override
    protected Void doInBackground(Void... params) {
        try {
            Bitmap myBitmap = BitmapFactory.decodeFile(Constant.image_paths.get(viewPager.getCurrentItem()));
            Bitmap newBit = rotate(myBitmap,45);
            saveToInternalStorage(newBit,Constant.image_paths.get(viewPager.getCurrentItem()));
        } catch (Exception e){
            Log.d("error","error in rotate");
        }
        return null;
   }
   @Override
   protected void onPostExecute(Void aVoid) {
       super.onPostExecute(aVoid);
       myViewPagerAdapter.notifyDataSetChanged();
   }
}.execute();
public static Bitmap rotate(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(),source.getHeight(), matrix, false);
}
private String saveToInternalStorage(Bitmap bitmapImage,String path) throws IOException {
    ContextWrapper cw = new ContextWrapper(getActivity());
    // path to /data/data/yourapp/app_data/imageDir
 //   File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
    // Create imageDir
    File mypath = new File(path);
    if(mypath.exists()){
        mypath.delete();
    }
    if(!mypath.exists()){
        mypath.createNewFile();
    }
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(mypath);
        // Use the compress method on the BitMap object to write image to the OutputStream
        bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return mypath.getAbsolutePath();
}    
 
     
    