title: Android Null object reference on parsing color
body: <p>Im trying to parse a color from a text file but it errors and crashes.</p>
  
  <p>I am getting the error in logcat when running the code:</p>
  
  <pre><code>   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char java.lang.String.charAt(int)' on a null object reference
  </code></pre>
  
  <p>The colors are being retrieved from a text file where the color strings are stored:</p>
  
  <pre><code>#01DF01
  #FF0000
  </code></pre>
  
  <p>Snippet of color Code:</p>
  
  <pre><code>  private void fillView2(View view, String dataset4Value, String dataset5Value, String dataset6Value) {
          TextView textView1 = (TextView) view.findViewById(R.id.textView1);
          TextView textView2 = (TextView) view.findViewById(R.id.textView2);
          TextView textView3 = (TextView) view.findViewById(R.id.textView3);
  
          textView1.setBackgroundColor(Color.parseColor(dataset4Value));
          textView2.setBackgroundColor(Color.parseColor(dataset5Value));
          textView3.setBackgroundColor(Color.parseColor(dataset6Value));
      }
  </code></pre>
  
  <p>Other code:</p>
  
  <pre><code> int maxDataSetSize = Math.max(data1.size(), Math.max(data2.size(), data3.size())) ;
  
          for (int i = 0; i &lt; maxDataSetSize; i++) {
              String dataset1Value = data1.size() &gt; i ? data1.get(i) : null;
              String dataset2Value = data2.size() &gt; i ? data2.get(i) : null;
              String dataset3Value = data3.size() &gt; i ? data3.get(i) : null;
  
              View statsRowview = getLayoutInflater().inflate(R.layout.stats_row, null);
  
              fillView(statsRowview, dataset1Value, dataset2Value, dataset3Value);
  
              tableStats.addView(statsRowview);
          }
  </code></pre>