NullPointerException using append method on a view in android?
<p>I am trying to populate data from database into a TextView using this code:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 TextView view = (TextView) findViewById(R.id.textView);

    db = (new DatabaseHelper(this)).getWritableDatabase();
    cursor = getCursor();
    cursor.moveToFirst();
    while (cursor.isAfterLast() == false) {
        String text =  cursor.getString(2);
       view.append(text);
        cursor.moveToNext();
    }
</code></pre>

<p>However I am getting a NullPointerException on this line:</p>

<pre><code> view.append(text);
</code></pre>

<p>and I am not sure about the reason as the view exists.</p>
