public static String getFileRealNameFromUri(Context context, Uri fileUri) {
if (context == null || fileUri == null) return null;
DocumentFile documentFile = DocumentFile.fromSingleUri(context, fileUri);
if (documentFile == null) return null;
return documentFile.getName();
}

See:

1. ContentResolver - 如何从Uri获取文件名

2. StackOverFlow: Get filename and path from URI from mediastore

android: 根据文件uri 获取文件名的更多相关文章

  1. FileUtils【获取SD卡根目录、读写文件、移动、复制、删除文件、获取文件名、后缀名操作类】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 封装了获取SD卡根目录路径.以及对文件读写.获取文件名等相关操作. 因为需要用到android.permission.READ_EX ...

  2. Android根据图片Uri获取图片path绝对路径的几种方法【转】

    在Android 编程中经常会用到Uri转化为文件路径,如我们从相册选择图片上传至服务器,一般上传前需要对图片进行压缩,这时候就要用到图片的绝对路径. 下面对我开发中uri转path路径遇到的问题进行 ...

  3. android开发 根据Uri获取真实路径

    Uri uri = data.getData(); String[] proj = { MediaStore.Images.Media.DATA }; Cursor actualimagecursor ...

  4. 从一个带有http://网络文件中获取文件名

    例如文件网址为: http://a.hiphotos.baidu.com/image/h%3D200/sign=c3da85e50123dd543e73a068e108b3df/80cb39dbb6f ...

  5. php 遍历文件夹及文件,获取文件名和文件路径存入数据库中

    <?php header("Content-Type:text/html; charset=gbk"); require('../../include/connect.php ...

  6. C#通过文件路径获取文件名小技巧

    string fullPath = @"\WebSite1\Default.aspx"; string filename = System.IO.Path.GetFileName( ...

  7. php文件路径获取文件名

    物理截取: $file = '/www/htdocs/inc/lib.inc.php'; $filename = basename($file); echo $filename, '<br/&g ...

  8. PHP 文件路径获取文件名

    物理截取 $file = '/www/htdocs/inc/lib.inc.php'; $filename = basename($file); echo $filename, '<br/> ...

  9. C#通过文件路径获取文件名

    string fullPath = @"\WebSite1\Default.aspx"; string filename = System.IO.Path.GetFileName( ...

随机推荐

  1. How To Use These LED Garden Lights

    Are you considering the lighting options for the outdoor garden? Depending on how you use it, LED ga ...

  2. MySQL对大小写敏感吗

    见字如面,见标题知内容.你有遇到过因为MYSQL对大小写敏感而被坑的体验吗? 之前看过阿里巴巴Java开发手册,在MySql建表规约里有看到: [强制]表名.字段名必须使用小写字母或数字 , 禁止出现 ...

  3. Java传(1)

    ____________________________去告诉世界,我已经横空出世了! 你好丫,世界! public class HelloWorld{ public static void main ...

  4. Redis 基本数据类型以及相应操作

    〇.常用命令 select <num> 选择库0~15 默认0号库 key * 查看当前库所有键(可以接正则表达式) exists <key> type <key> ...

  5. C编程题总结

    最大子序列和: 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: ...

  6. MyBatis(4)——配置文件优化

    配置文件优化 执行流程:读取配置流程->sqlSessionFactory->sqlSession(连接.读取sql并执行相应操作.关闭) a)配置优化:通过中文参考指南的说明可知-> ...

  7. 普及C组第二题(8.2)

    1340. [南海2009初中]jumpcow(牛跳) (Standard IO) 题目: John的奶牛们计划要跳到月亮上去.它们请魔法师配制了 P (1 <= P <=150,000) ...

  8. bugku 好多压缩包

    https://www.cnblogs.com/WangAoBo/p/6951160.html

  9. MySQL必知必会(第4版)整理笔记

    参考书籍: BookName:<SQL必知必会(第4版)> BookName:<Mysql必知必会(第4版)> Author: Ben Forta 说明:本书学习笔记 1.了解 ...

  10. Java 常见异常及处理方案

    Java 常见异常处理方案 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的. 比如说,你的代码少了一个分号,那么运行出来结果是提示是错误java.lang.Error: ...