Android 如何从SD卡中检索图像
我有这个代码从SD卡中检索图像。但是它在Android 如何从SD卡中检索图像,android,android-sdcard,Android,Android Sdcard,我有这个代码从SD卡中检索图像。但是它在ImageView中没有显示任何图片。我确信SD卡上有图像 File f = new File("/mint/sdcard/e.jpg"); Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath()); Toast.makeText(this, bitmap + "", 3).show(); bmImage.setImageBitmap(bitmap); 像这样改变它 File f = n
ImageView
中没有显示任何图片。我确信SD卡上有图像
File f = new File("/mint/sdcard/e.jpg");
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
Toast.makeText(this, bitmap + "", 3).show();
bmImage.setImageBitmap(bitmap);
像这样改变它
File f = new File("/mnt/sdcard/e.jpg");
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
bmImage .setImageBitmap(bitmap);
它不是
mint
Itsmnt
。把你的台词写成
File f = new File("/mnt/sdcard/e.jpg");
您不必使用“/mnt/sdcard/e.jpg”
。您必须使用此方法:
Environment.getExternalStorageDirectory().toString()
因为它将返回外部目录的正确路径。制造商可以将其重命名为其他名称,因此您必须使用上述方法。最好使用以下方法:
File sdcard = Environment.getExternalStorageDirectory();
File f = new File(sdcard+"/e.jpg");
现在它可以在所有Android手机上运行了its not
mint
itsmnt
在写了之后它仍然不工作……你在logcat上收到任何错误消息了吗?是的,它的mnt谢谢……它现在可以工作了……你可能应该接受@vini下面的答案,因为他是第一个参加舞会的人。:)向OP提及所做的更改(尽管您在上面发表了评论)
File sdcard = Environment.getExternalStorageDirectory();
File f = new File(sdcard+"/e.jpg");