Code example for Activity

Methods: managedQuery

0
	 */ 
	public static String getLatestImage(Activity context)
	{ 
		String latestImage = null;
		String[] items = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA }; 
		Cursor cursor = context.managedQuery(
		                                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
		                                items, 
		                                null, 
		                                null,  
		                                MediaStore.Images.Media._ID + " desc");
		 
		if( cursor != null && cursor.getCount()>0 )
		{ 
			cursor.moveToFirst();
			for( cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext() )
			{ 
				latestImage = cursor.getString(1);
				break; 
			} 
		}