Uri: getLastPathSegment()

该函数可用于截取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()

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/554380/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球