0

我正在做一个模块,它从服务器获取图像并保存在手机的内部存储中,图像获取部分已完成,但是当我单击某些手机中的保存按钮时,图像成功存储但未存储在 MIUI 操作系统中。

//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();
}

我得到了“保存在画廊中!” 吐司,但在存储内部没有文件夹和图像文件

4

1 回答 1

0

记录外部存储目录的路径并签入相应的文件夹。

于 2019-07-25T06:01:23.503 回答