Android have inbuilt functions to retrive list.
Following is demo for Image list. for audio , video and even for other types of file you can use similar functions.
Following is demo for Image list. for audio , video and even for other types of file you can use similar functions.
/**
* Used to get images from whole phone
*/
public void get_all_image_folders() {
// which image properties are we querying
String[] projection = new String[] { MediaStore.Images.Media._ID,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
MediaStore.Images.Media.DATE_TAKEN
};
Uri images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// Make the query.
String sortOrder = MediaStore.Images.Media.DATE_TAKEN + " Desc";
Cursor cur = getContentResolver().query(images, projection, null,null, sortOrder);
if (cur.moveToFirst()) {
String bucket;
String date;
int bucketColumn = cur
.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
int dateColumn = cur
.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN);
do {
// Get the field values
bucket = cur.getString(bucketColumn);
date = cur.getString(dateColumn);
// Do something with the values.
Log.i("ListingImages", " bucket=" + bucket + " date_taken="
+ date + "" );
} while (cur.moveToNext());
}
}
No comments :
Post a Comment