Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're not keeping track of which video ID is being clicked on.</p> <p>Once you have that, you can (presumably) get the path to the video by querying the <code>ContentProvider</code> (like you do in <code>VideoAdapter</code>). Or, simpler &mdash; since you're already querying for <code>MediaStore.Video.Media.DATA</code> &mdash; attach the URL to the view with <code>convertView.setTag()</code>.</p> <p>You could store this in a local variable during the <code>onItemClick</code> call &mdash; the URI should be available directly by calling <code>String uri = (String) v.getTag()</code>.</p> <p>Some further notes: </p> <ul> <li>Don't call <code>System.gc()</code>, especially not in a <code>getView()</code> method. That will cause a huge number of unnecessary slowdowns.</li> <li>Don't call <code>vContext.getApplicationContext()</code>; just use <code>vContext</code>.</li> <li>You're not recycling views properly. Your <code>getView</code> should look more like below:</li> </ul> <hr> <pre><code>private static int displayNameIndex = -1; public View getView(int position, View convertView, ViewGroup parent) { TextView tv; if (convertView == null) { // Need to create a new view tv = new TextView(context); } else { // Otherwise, we can recycle the one given to us tv = (TextView) convertView; } // Bind cursor data to UI videocursor.moveToPosition(position); id = videocursor.getString(1); // column index of Media.DISPLAY_NAME tv.setText(id); // Bundle video URI into the view String videoUri = videocursor.getString(2); // column index of Media.DATA tv.setTag(videoUri); return tv; } </code></pre> <p>I would also look at CursorAdapter, rather than having to do cursor stuff yourself (moving the cursor to the right position etc.).</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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