Uri: getLastPathSegment()

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

content://media/external/file/61585

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

61585

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

String path = fileUri.getPath();
path.substring(path.lastIndexOf("/") + 1);
posted @ 2022-03-14 15:25  夜行过客  阅读(818)  评论(0编辑  收藏  举报