Frage

Hi I have 2 different codes

  1. To open the selected folder is imagecursor
  2. To show only images of size less than 1Mb is sizeCursor

    final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media.SIZE,MediaStore.Images.Media._ID};
    
    imagecursor=managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns,MediaStore.Images.Media.DATA + " like ? ", new String[] {"%/"+foldername+"/%"},null);
    
    Cursor sizeCursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns,MediaStore.Images.Media.SIZE + " < ? ",new String[] {"1024"},null); 
    

Now I want to combine both into a single query, like show the images less than 1MB from selected folder

War es hilfreich?

Lösung

The selection parameter is just an SQL expression, so you can combine multiple predicates with AND:

managedQuery(..., ...DATA + " LIKE ? AND " + ...SIZE + " < ?",
             new String[] { "%/"+foldername+"/%", "1024" }, ...);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top