I'd like to get the full file path, from a URI. The URI isn't a Image, but it's a music file, but if i do it like the MediaStore Solution, it won't work if the app user selects eg Astro as browser, instead of Music Player. How do I solve this?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- C#中 public virtual string Category { get; }这么写会报错:
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
I had a hard time trying to figure this out on Xamarin. From the suggestions above I came up with this solution.
You can use get File path from diffrent SDk versions
Use RealPathUtils for it
**Now get the file Path from URI **
Use:
or
Now call
FileUtils.getPath(context, uri);
from your main class.Try this.
The PathUtil method will be only working in below oreo and if it is oreo than it is likely to crash because in oreo we will not get the id but the entire path in data.getData() so all u need to do is create a file from uri and get its path from getPath() and split it.below is the working code:-
The above code will work in oreo and if it is below oreo than PathUtil will work.Thanks!
PathUtil.java