uri转file:
[html] view plain copy print?
file = new File(new URI(uri.toString()));
uri转path:
[html] view plain copy print?
private String getPath(Uri uri) {
String[] projection = {MediaStore.Video.Media.DATA};
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
file转uri:
[html] view plain copy print?
URI uri = file.toURI();
file转path:
[html] view plain copy print?
String path = file.getPath()
path转uri:
[html] view plain copy print?
Uri uri = Uri.parse(path);
path转file:
[html] view plain copy print?
File file = new File(path)