如何获取用FileOutputStream保存的文件的URI?

Eth*_*len 4 java android uri android-file

这是将图像文件保存到...某处的代码?如何获取文件“ webimage”的URI?

Bitmap bmp = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
        String fileName = "webImage";//no .png or .jpg needed
        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            bmp.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            FileOutputStream fo = openFileOutput(fileName, Context.MODE_PRIVATE);
            fo.write(bytes.toByteArray());
            // remember close file output
            fo.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

Bob*_*der 5

像这样使用getFileStreamPath()

String fileName = "webImage";
//...
Uri uri = Uri.fromFile(getFileStreamPath(fileName));
Run Code Online (Sandbox Code Playgroud)