android - cursor limit photos -
how limit photos till top 50? jho recent records here?
final string[] projection = { mediastore.images.media.data }; final string selection = mediastore.images.media.bucket_id + " = ?"; final string[] selectionargs = { camera_image_bucket_id }; final cursor cursor = context.getcontentresolver().query(images.media.external_content_uri, projection, selection, selectionargs, null); list<image> result = new arraylist<image>(cursor.getcount()); if (cursor.movetofirst()) { final int datacolumn = cursor.getcolumnindexorthrow(mediastore.images.media.data); { final string data = cursor.getstring(datacolumn); result.add(new image(data)); } while (cursor.movetonext()); } cursor.close();
thank in advance
string sortorder = string.format("%s limit 50 ", images.imagecolumns.date_taken + " desc"); final cursor cursor = context.getcontentresolver().query(images.media.external_content_uri, projection, selection, selectionargs, sortorder);
sorts images created date , limits them 50 recent.
Comments
Post a Comment