Uri: getLastPathSegment()

技术杂谈83

该函数可用于截取URI当中的文件名。
比如一段 URI如下:

content://media/external/file/61585

调用该函数得到的结果为:

61585

也就是简化了下面的代码:

String path = fileUri.getPath();
path.substring(path.lastIndexOf("/") + 1);

Original: https://www.cnblogs.com/yongdaimi/p/16004259.html
Author: 夜行过客
Title: Uri: getLastPathSegment()