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. 配置yum仓库:yum install 软件

    1.一个重要模板: 进入/etc/yum.repos.d文件夹,新建一个xiaoxu.repo文件,其中xiaoxu可以根据需要来取名. [模板] vim  xiaoxu.repo [rhel]    ...

  2. JavaScript错误-throw、try和catch

    try 语句测试代码块的错误. catch 语句处理错误. throw 语句创建自定义错误. finally 语句在 try 和 catch 语句之后,无论是否有触发异常,该语句都会执行. JavaS ...

  3. Bugku-CTF之你从哪里来

    Day 27 你从哪里来 http://123.206.87.240:9009/from.php 本题要点: http referer头的修改     查看源码什么也没有   抓个包看一下

  4. Codeforces 1315C Restoring Permutation

    You are given a sequence b1,b2,…,bnb1,b2,…,bn . Find the lexicographically minimal permutation a1,a2 ...

  5. 联合查询:union

    1.联合查询:union 1.1 作用:将多条select语句的结果,合并到一起,称之为联合操作. 1.2 语法:( ) union ( ); 例子:(select name from info_or ...

  6. Centos6.10-FastDFS-Tracker.conf示例配置

    Centos610系列配置 FastDFS_Tracker.conf示例配置 # is this config file disabled # false for enabled # true for ...

  7. Django 报错no sucn column: OpretionalError

    1.报错原因:新增的字段未能同步数据库 2.解决办法:删除整个数据库,然后重新编译,然后over 1.rm -rf db.sqlites3 #删除数据库 2.rm -rf cmdb/migrarion ...

  8. 关于jsp的action如何调用servlet的自定义方法

    一.起因: 希望将同属于某个模块的简单功能整合到一起,不创建太多的servlet 二.问题描述: action或者method属性是否能直接调用自定义方法 三.补充知识点: 查询得知:servelet ...

  9. sshpass远程登陆

    1,ssh ssh 端口为默认22的时候: sshpass -p 888888 scp -o StrictHostKeyChecking=no /root/images.zip root@21.1.9 ...

  10. buuctf Easysql 小记

    堆叠注入 利用原理: 补充系统变量@@sql_modesql_mode:是一组mysql支持的基本语法及校验规则PIPES_AS_CONCAT:将“||”视为字符串的连接操作符而非或运算符,这和Ora ...