android 7.0 图片path转Uri

来源:互联网 发布:叶如何知秋 编辑:程序博客网 时间:2024/06/01 08:53

Uri uri = null;


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {


//如果是7.0android系统

ContentValues contentValues = new ContentValues(1);


contentValues.put(MediaStore.Images.Media.DATA,path);


uri=cipCxt.getCIActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,contentValues);


}else{


uri = Uri.fromFile(new File(path));


}