Reputation: 633
I'm developing an application about data in device like count sms, mails. I can't find the way to get the amount of pictures.
How can I get the amount of pictures stored in the device? Any suggestions are welcome.
Upvotes: 2
Views: 185
Reputation: 2882
You can try with a query.
Something like this (this code was not intended for this goal, however i think this is the way to go):
Uri imagesUri = MediaStore.Images.Media.getContentUri("external"); // for SD Card only
String[] fields = {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATA
};
Cursor cursor = getBaseContext().getContentResolver().query(
imagesUri,
fields,
MediaStore.Images.ImageColumns.DATA+" = '*'" ,
null,
null);
num_images = cursor.getCount();
I didn't try this, i used something like this to get all ordered images from a folder.
Try using directly the COUNT keyword in the query.
Hope this helps.
Upvotes: 1