Cursor cursor = managedQuery(Uri, null, null, null, null);
- First parameter are used for what you want to access there are built-in Uri used to access desired contents.
- Browser.BOOKMARKS_URI
- Browser.SEARCHES_URI
- CallLog.CONTENT_URI
- MediaStore.Images.Media.INTERNAL_CONTENT_URI
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI
- Settings.CONTENT_URI
For Images
String[] projection = { MediaStore.Images.Thumbnails._ID, MediaStore.Images.Media.DATA ,MediaStore.Images.Thumbnails.DATA}
Cursor cursor = managedQuery(Uri, projection, null, null, null);
Cursor cursor = managedQuery(Uri, projection, null, null, null);
For Contact
Uri contacts=Uri.parse("People.CONTENT_URI");
String[]projection=newString[]
{ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER};
Cursorc=managedQuery(contacts,projection,
null,null,null);
String[]projection=newString[]
{ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER};
Cursorc=managedQuery(contacts,projection,
null,null,null);
3. The Third and Fourth parameter are used for Filtering retrieved data. Its also called WHERE clause of SQL . Now we want to retrieved all sContacts names which are start from Alphabetic A and end with any string.
String Filter="ContactsContract.Contacts.DISPLAY_NAME+“"LIKE 'A' OR 'a',";
Cursorc=managedQuery(contacts,projection,
filter,null,null);
4. Now we used Third and fourth parameter together for filteringCursorc=managedQuery(contacts,projection,
filter,null,null);
String filterColumn=ContactsContract.Contacts.DISPLAY_NAME+“LIKE?”,
String[] filterName={"'a' OR 'A' "};
Cursorc=managedQuery(contacts,projection, filterColumn,filterName,null);
5. Fifth parameter are used for Sorting retrieved record . Its work like SQL ORDER BY. You can arrange record in ascending and descending orderString[] filterName={"'a' OR 'A' "};
Cursorc=managedQuery(contacts,projection, filterColumn,filterName,null);
String sorting="ContactsContract.Contacts.DISPLAY_NAME+"DESC" "
Cursorc=managedQuery(contacts,projection, filterColumn,filterName,sorting);
Cursorc=managedQuery(contacts,projection, filterColumn,filterName,sorting);
0 Comments