0

I'm doing a module which is get images from server and save in internal storage of phone, Image fetching part in done but when i click on save button in some phones images store successfully but not store in MIUI operating system.

//Method for Save Image in Directory
private void saveSessionImage(int position, Bitmap bitmap, String se_photo_id_pk) {
    File file;
    String path = Environment.getExternalStorageDirectory().toString();
    File myDir = new File(path + "/FolderName");
    if (!myDir.exists()) {
        myDir.mkdirs();
    }
    file = new File(myDir, "IMG_SESSION"+se_photo_id_pk+".jpg");
    if (file.exists ()) {
        file.delete ();
    }
    try{
        OutputStream stream;
        stream = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream);
        stream.flush();
        stream.close();
    }
    catch (IOException e) // Catch the exception
    {
        e.printStackTrace();
    }
    // Display saved image uri to TextView
    Toast.makeText(context, "Saved in Gallery!", Toast.LENGTH_SHORT).show();
    itemSessionPhotosList.remove(position);
    notifyDataSetChanged();
}

i got "Saved in Gallery!" toast but inside storage there is no folder as well as image file

  • Hi, you can format text as a code with 3 symbols " ` " at the beginning of the code and 3 " ` " at the end. – Bulat Jul 25 '19 at 05:58

1 Answers1

0

Log the path of external storage directory and check in the respective folder.

Subham Dubey
  • 60
  • 1
  • 7