【问题标题】:How to create folder in MIUI 10 programmatically?如何以编程方式在 MIUI 10 中创建文件夹?
【发布时间】:2019-07-25 05:52:40
【问题描述】:

我正在做一个模块,它从服务器获取图像并保存在手机的内部存储中,图像获取部分已完成,但是当我单击某些手机中的保存按钮时,图像成功存储但未存储在 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();
}

我得到了“保存在图库中!” toast,但在存储中没有文件夹和图像文件

【问题讨论】:

  • 您好,您可以将文本格式化为代码,代码开头3个符号“`”,末尾3个“`”。

标签: android miui


【解决方案1】:

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

【讨论】:

  • 以上代码在某些手机上工作,但是当我在 MI 最新手机上运行我的应用程序时,它没有结果
猜你喜欢
  • 2020-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多