title: java.lang.NullPointerException: uriString
body: <p>I am a newbie and trying to create a video player .I am getting a null pointer exception and have read all the questions on SO and searched google related to it and read it. <code>thumbpath</code> doesn't seem null to me although it maybe the only reason of this exception. Can anyone help me with it ? Thanks</p>
  
  <p><strong>SDVideos.java</strong>  </p>
  
  <pre><code>package com.example.dell_1.myapp3;
  
  import android.app.Activity;
  import android.content.Context;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.MediaStore;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class SDVideos extends Activity
  {
      private Cursor videoCursor;
      private int videoColumnIndex;
      ListView videolist;
      int count;
      String thumbPath;
  
      String[] thumbColumns = { MediaStore.Video.Thumbnails.DATA,MediaStore.Video.Thumbnails.VIDEO_ID };
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_sdvideos);
          initialization();
      }
  
      private void initialization()
      {
          System.gc();
          String[] videoProjection = { MediaStore.Video.Media._ID,MediaStore.Video.Media.DATA,
                  MediaStore.Video.Media.DISPLAY_NAME,MediaStore.Video.Media.SIZE };
          videoCursor =getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,videoProjection, null, null, null);
          count = videoCursor.getCount();
          videolist = (ListView) findViewById(R.id.PhoneVideoList);
  
          videolist.setAdapter(new VideoListAdapter(this.getApplicationContext()));
          videolist.setOnItemClickListener(videogridlistener);
      }
  
      private AdapterView.OnItemClickListener videogridlistener = new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView parent, View v, int position, long id)
          {
              videoColumnIndex = videoCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
              videoCursor.moveToPosition(position);
              String filename = videoCursor.getString(videoColumnIndex);
              Log.i("FileName: ", filename);
  //Intent intent = new Intent(VideoActivity.this, ViewVideo.class);
  //intent.putExtra("videofilename", filename);
  //startActivity(intent);
          }};
  
      public class VideoListAdapter extends BaseAdapter
      {
          private Context vContext;
  
          public VideoListAdapter(Context c)
          {
              vContext = c;
          }
  
          public int getCount()
          {
              return videoCursor.getCount();
          }
  
          public Object getItem(int position)
          {
              return position;
          }
  
          public long getItemId(int position)
          {
              return position;
          }
  
          public View getView(int position, View convertView, ViewGroup parent)
          {
              View listItemRow;
              listItemRow = LayoutInflater.from(vContext).inflate(R.layout.listitem, parent, false);
  
              TextView txtTitle = (TextView)listItemRow.findViewById(R.id.txtTitle);
              TextView txtSize = (TextView)listItemRow.findViewById(R.id.txtSize);
              ImageView thumbImage = (ImageView)listItemRow.findViewById(R.id.imgIcon);
  
              videoColumnIndex = videoCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
              videoCursor.moveToPosition(position);
              txtTitle.setText(videoCursor.getString(videoColumnIndex));
  
              videoColumnIndex = videoCursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE);
              videoCursor.moveToPosition(position);
              txtSize.setText(" Size(KB):" + videoCursor.getString(videoColumnIndex));
  
              int videoId = videoCursor.getInt(videoCursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID));
              Cursor videoThumbnailCursor =getContentResolver().query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,
                      thumbColumns, MediaStore.Video.Thumbnails.VIDEO_ID+ "=" + videoId, null, null);
  
              if (videoThumbnailCursor.moveToFirst())
              {
                  thumbPath = videoThumbnailCursor.getString(videoThumbnailCursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
                  Log.i("ThumbPath: ",thumbPath);
              }
              thumbImage.setImageURI(Uri.parse(thumbPath));
              return listItemRow;
          }
      }
  }
  </code></pre>
  
  <p><strong>XML File :</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
      &lt;ListView
          android:id="@+id/PhoneVideoList"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:divider="#242424"
          android:dividerHeight="1dp"/&gt;
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>LOGCAT :</strong></p>
  
  <pre><code>08-05 17:29:17.109 17708-17708/com.example.dell_1.myapp3 E/AndroidRuntime: FATAL EXCEPTION: main
          Process: com.example.dell_1.myapp3, PID: 17708
          java.lang.NullPointerException: uriString
          at android.net.Uri$StringUri.&lt;init&gt;(Uri.java:475)
      at android.net.Uri$StringUri.&lt;init&gt;(Uri.java)
      at android.net.Uri.parse(Uri.java:437)
      at com.example.dell_1.myapp3.SDVideos$VideoListAdapter.getView(SDVideos.java:112)
      at android.widget.AbsListView.obtainView(AbsListView.java:2367)
      at android.widget.ListView.makeAndAddView(ListView.java:1972)
      at android.widget.ListView.fillDown(ListView.java:704)
      at android.widget.ListView.fillFromTop(ListView.java:765)
      at android.widget.ListView.layoutChildren(ListView.java:1744)
      at android.widget.AbsListView.onLayout(AbsListView.java:2161)
      at android.view.View.layout(View.java:17523)
      at android.view.ViewGroup.layout(ViewGroup.java:5618)
      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
      at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
      at android.view.View.layout(View.java:17523)
      at android.view.ViewGroup.layout(ViewGroup.java:5618)
      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
      at android.view.View.layout(View.java:17523)
      at android.view.ViewGroup.layout(ViewGroup.java:5618)
      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
      at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
      at android.view.View.layout(View.java:17523)
      at android.view.ViewGroup.layout(ViewGroup.java:5618)
      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
      at com.android.internal.policy.DecorView.onLayout(DecorView.java:724)
      at android.view.View.layout(View.java:17523)
      at android.view.ViewGroup.layout(ViewGroup.java:5618)
      at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2374)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2101)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1278)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6357)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
      at android.view.Choreographer.doCallbacks(Choreographer.java:683)
      at android.view.Choreographer.doFrame(Choreographer.java:619)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
      at android.os.Handler.handleCallback(Handler.java:751)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6077)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  </code></pre>