Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecify a folder in MediaStore managedQuery
    primarykey
    data
    text
    <p>Hi i want to specify a folder on the SD card to retrieve all of images in a subfolder of that folder (ex, /mnt/sdcard/Folder/SubFolder). I've this:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery); GridView gridview = (GridView) findViewById(R.id.gallery); registerForContextMenu(gridview); id = getIntent().getExtras().getString("ID"); // Set up an array of the Thumbnail Image ID column we want String[] projection = {MediaStore.Images.Thumbnails._ID}; // Create the cursor pointing to the SDCard cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, // Which columns to return null, // Return all rows null, MediaStore.Images.Thumbnails.IMAGE_ID); // Get the column index of the Thumbnails Image ID columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID); </code></pre> <p>And in setAdapter of my gridview i have:</p> <pre><code>gridview.setAdapter(new BaseAdapter() { public View getView(int position, View convertView, ViewGroup parent) { ImageView picturesView; if (convertView == null) { picturesView = new ImageView(mContext); // Move cursor to current position cursor.moveToPosition(position); // Get the current value for the requested column int imageID = cursor.getInt(columnIndex); // Set the content of the image based on the provided URI picturesView.setImageURI(Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID)); picturesView.setScaleType(ImageView.ScaleType.FIT_CENTER); picturesView.setPadding(8, 8, 8, 8); picturesView.setLayoutParams(new GridView.LayoutParams(100, 100)); } else { picturesView = (ImageView)convertView; } return picturesView; } public int getCount() { return cursor.getCount(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } }); </code></pre> <p>That's works but show me all images contained in sdcard... I've tried to set a URI path, like "content:///mnt/sdcard/folder/subfolder" but it doesen't work...How can I specify, in MediaStore managedQuery, a specific folder to scan?? </p> <p>Thank you all in advance! :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload