您的位置:首页 > 移动开发 > Android开发

android intent 选择文件

2015-11-05 13:07 507 查看
我们很多时候会遇到需要选择手机文件用来编辑、上传等功能

我们可以通过

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, code);

然后在OnACtivityResult中获取选中的文件信息,但是需要注意的是,通过data.getData()方法返回的是Uri

文件的路径是通过data.getData().getPath()得到的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android file intent uri