title: Display thumbnail of video
body: <p>I need to display thumbnail of each video in list view using Picasso library for running faster so i need get thumbnail path to use.</p>
  
  <p>This is my code to get thumbnail path(I found it on Google and i change something to adapt for my application):</p>
  
  <pre><code>String getThumbnailPathForLocalFile(Uri uri)
       {
           Cursor thumbCursor = null;
           try
           {
               thumbCursor = c.getContentResolver().
                       query(uri
                       , null
                       , null , null, null);
  
               if(thumbCursor.moveToFirst())
               {
                   // the path is stored in the DATA column
                   int dataIndex = thumbCursor.getColumnIndexOrThrow( MediaStore.MediaColumns.DATA );
                   String thumbnailPath = thumbCursor.getString(dataIndex);
                   return thumbnailPath;
               }
           }
           finally
           {
               if(thumbCursor != null)
               {
                   thumbCursor.close();
               }
           }
  
           return null;
       }
  </code></pre>
  
  <p>My getView function:</p>
  
  <pre><code>@Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View v = convertView;
          if (v == null) {
              LayoutInflater vi = (LayoutInflater) c
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              v = vi.inflate(R.layout.listview_item, null);
          }
  
          /* create a new view of my layout and inflate it in the row */
          // convertView = ( RelativeLayout ) inflater.inflate( resource, null );
  
          final Item item = items.get(position);
          if (item != null) {
              TextView t1 = (TextView) v.findViewById(R.id.txt_fileName);
              imageCity = (ImageView) v.findViewById(R.id.img_icon);
  
              switch (item.getType()) {
              case "video":
                  String uri2 = item.getPath();
                  Uri videoUri = MediaStore.Video.Thumbnails
                          .getContentUri(uri2);
                  String VideoThumbnailPath =getThumbnailPathForLocalFile(videoUri);
                  Picasso.with(c).load(new File(VideoThumbnailPath))
                          .resize(64, 64).into(imageCity);
                  break;
              case "image":
                  String uri4 = item.getPath();
                  Picasso.with(c).load(new File(uri4)).resize(64, 64).into(imageCity);
                  break;
              default:
                  break;
              }
  
  
              if (t1 != null)
                  t1.setText(item.getName());
  
          }
          return v;
      }
  </code></pre>
  
  <p>I check logcat and debug so i found that thumbCursor is null:</p>
  
  <pre><code>12-10 17:52:38.400: E/AndroidRuntime(8659): java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference
  12-10 17:52:38.400: E/AndroidRuntime(8659):     at com.example.knock.FileArrayAdapter.getThumbnailPathForLocalFile(FileArrayAdapter.java:105)
  12-10 17:52:38.400: E/AndroidRuntime(8659):     at com.example.knock.FileArrayAdapter.getView(FileArrayAdapter.java:73)
  </code></pre>
  
  <p>Anybody can help me ?
  Thanks you very much</p>