uri,file,path互相转化

2017-12-24 11:43:48

uri转file:


[html] view plain copy print?

  1. file = new File(new URI(uri.toString()));  


uri转path:



[html] view plain copy print?

  1. private String getPath(Uri uri) {  

  2.        String[] projection = {MediaStore.Video.Media.DATA};  

  3.        Cursor cursor = managedQuery(uri, projection, null, null, null);  

  4.        int column_index = cursor  

  5.                .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);  

  6.        cursor.moveToFirst();  

  7.        return cursor.getString(column_index);  

  8.    }  




file转uri:


[html] view plain copy print?

  1. URI uri = file.toURI();  



file转path:


[html] view plain copy print?

  1. String path = file.getPath()  





path转uri:


[html] view plain copy print?

  1. Uri uri = Uri.parse(path);  


path转file:



[html] view plain copy print?

  1. File file = new File(path)  



  • 2020-05-07 13:42:13

    场景切换的集合移动,旋转,淡入淡出等

    两个场景(即两个div视图)切换的时候,如果想添加个过渡动画,除了可以使用js来实现,还可以通过CSS3的animation属性来实现。 (注意:Internet Explorer 9 以及更早的版本不支持 animation 属性。)

  • 2020-05-07 13:43:02

    css模拟开关按钮

    之前我们为大家分享过很多款各式各样的CSS3开关切换按钮,很多还是非常富有创意的,比如这里的多组超具创意的CSS3开关切换按钮和纯CSS3灯光开关动画。今天我们要带来另外一款外观很漂亮的纯CSS3开关切换按钮动画,它模拟了电灯的开关,并且在开和关之间切换时按钮的背景会有不同的变化,看起来非常不错。

  • 2020-05-07 18:40:35

    CSS让页面平滑滚动

    凡是需要滚动的地方都加一句scroll-behavior:smooth就好了!

  • 2020-05-12 10:17:07

    createElementNS和createElement区别

    指定与元素相关联的命名空间URI的字符串。创建的元素的namespaceURI属性使用namespaceURI的值进行初始化。 参见有效的命名空间URL。

  • 2020-05-13 09:37:50

    transform-origin(变形原点) 怎么用

    transform-origin是变形原点,也就是该元素围绕着那个点变形或旋转,该属性只有在设置了transform属性的时候起作用

  • 2020-05-13 09:56:35

    Could not find method google() for arguments [] on repository container.

    1、打开项目根目录下android/gradle/wrapper/gradle-wrapper.properties 将distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip中的2.14.1改成4.1 ———————————————— 版权声明:本文为CSDN博主「peachesTao」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/taoerchun/article/details/93870941

  • 2020-05-13 10:05:23

    inline svg想写介绍以及使用

    inline svg是目前前端图标解决方案的最优解(当然不仅限于图标),而且使用方式也及其简单,只要将svg图标代码当成普通的html元素来使用即可