Android 是否在ImageView中显示存储在内部存储器中的图像?我做错了什么?

Android 是否在ImageView中显示存储在内部存储器中的图像?我做错了什么?,android,uri,android-imageview,android-file,Android,Uri,Android Imageview,Android File,我首先以以下方式将图像存储在内部存储器中: FileOutputStream fos = context.openFileOutput("myimage.png", Context.MODE_PRIVATE); bitmap.compress(CompressFormat.PNG, 100, fos); fos.close(); File filepath = context.getFileStreamPath("myimage.png"); Uri uri = Uri.parse(filep

我首先以以下方式将图像存储在内部存储器中:

FileOutputStream fos = context.openFileOutput("myimage.png", Context.MODE_PRIVATE);
bitmap.compress(CompressFormat.PNG, 100, fos);
fos.close();
File filepath = context.getFileStreamPath("myimage.png");
Uri uri = Uri.parse(filepath.toString());
myImageView.setImageUri(uri);
然后我在
图像视图中以这种方式显示它:

FileOutputStream fos = context.openFileOutput("myimage.png", Context.MODE_PRIVATE);
bitmap.compress(CompressFormat.PNG, 100, fos);
fos.close();
File filepath = context.getFileStreamPath("myimage.png");
Uri uri = Uri.parse(filepath.toString());
myImageView.setImageUri(uri);
但是图像从未出现在
图像视图中。由于某些限制,我无法在此处使用
setImageBitmap()
。谁能告诉我哪里出了问题


谢谢你的帮助

您可以尝试以下操作:

而不是
context.getFileStreamPath(“myimage.png”)
您可以尝试
Uri=Uri.parse(getFilesDir().getPath()+“/myimage.png”);

您可以尝试以下操作:

而不是
context.getFileStreamPath(“myimage.png”)
您可以尝试
Uri=Uri.parse(getFilesDir().getPath()+“/myimage.png”);


您是否在清单中添加了
?位图是如何声明的?写入\外部\存储不是必需的,因为我使用内部存储进行读/写操作。对于位图,我首先打开库,然后在选择图像时,对其使用BitmapFactory.decodeFile()。这部分很好用。问题出在ImageView部分。好的,然后尝试
filepath.getPath()
而不是
filepath.toString()
您是否在清单中添加了
?位图是如何声明的?写入\外部\存储不是必需的,因为我使用内部存储进行读/写操作。对于位图,我首先打开库,然后在选择图像时,对其使用BitmapFactory.decodeFile()。这部分很好用。问题出在ImageView部分。好的,然后尝试
filepath.getPath()
而不是
filepath.toString()
Bitmap b=BitmapFactory.decodeFile(getFilesDir().getAbsolutePath()+“/myimage.png”);位图b=BitmapFactory.decodeFile(getFilesDir().getAbsolutePath()+“/myimage.png”);