Skip to content Skip to sidebar Skip to footer

How To Show Only Videos Folder?

I am working on an android app, please tell me, How to show only videos folder? this code shows all folder in my device, But I want to show only videos folder. How to do that? here

Solution 1:

There's no simple way to do this in Android. It's a mistake to assume that there will be only one directory videos/ on a particular device. Even if there is, you can't assume that video files will be stored there, and nowhere else.

If you really only want to scan one directory, then a simple approach is to prompt the user for the location when your app first starts, and store the selected location for future use. Many android apps that handle media do, in fact, take this approach -- although they might allow the user to select multiple locations.

If you want to list video files, rather than the contents of a specific directory, then the way to do this is to query the Android media store. This store is (or should be) updated whenever files are transferred to the device. Each file is tagged with various attributes according to various inspection methods built into Android. Modern Android versions are pretty good at recognizing video files, although that wasn't always the case.

To use the media store, you'd do a query on the ContentResolver for a specific Context, testing for a flag that indicates that the content is video. Then you'd iterate the results, extracting the various pieces of information you need.

To be honest, I've not used the Android media store for video, although I have for audio. I think the basic principles will be the same. I have some sample code for audio queries here, if that's any help:

https://github.com/kevinboone/androidmusicserver/blob/master/src/net/kevinboone/androidmusicplayer/AudioDatabase.java

Post a Comment for "How To Show Only Videos Folder?"