0
我正在使用下面的代码来浏览和从SD卡中选择文件。在Android中打开文件
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent,PICKFILE_RESULT_CODE);
当用户选择了一个文件,我取使用此行代码的路径
String picturePath = data.getData().getPath();
但是当我尝试使用打开该文件下面的代码,我收到文件未发现异常
InputStream inputStream = getContentResolver().openInputStream(Uri.fromFile(new File(picturePath)));
我得到这个作为路径选择的文件
/external/images/media/36
我该如何在android中做到这一点?
感谢
你用什么版本的android测试? – Marcelo
我正在使用android 2.2 – Zach
该路径有些奇怪,它缺少文件扩展名。它看起来像你正在选择一个图像,所以应该有一个文件扩展名。 – Marcelo