title: Error in fetching data from database table
body: <p>I am making an android app. and am trying to fetching data from column, name and score from </p>
  
  <p>the database table but getting this error at run time, </p>
  
  <p>Sorry this application has stopped unexpectedly.</p>
  
  <p>This is my Code from Database Class,</p>
  
  <pre><code>public long addscore(String name, int score)
  {
  
      ContentValues values = new ContentValues();
      values.put(KEY_name, name); 
      values.put(KEY_score, score);
  
      // Inserting Row
      return db.insert(DATABASE_TABLE, null, values);
  }
  public Cursor getScore(long rowId) throws SQLException 
  {
      Cursor mCursor = db.query(true,DATABASE_TABLE, new String[] {
              KEY_scoreid,KEY_name,KEY_score },,KEY_scoreid + "="
              + rowid,null,null,null,null,null);
      if (mCursor != null) 
      {
          mCursor.moveToFirst();
      }
      return mCursor;
  
  }
  </code></pre>
  
  <p>And this is the code of class from where i m trying to </p>
  
  <p>fetch the Data from Database table (Highscore.java), </p>
  
  <pre><code>public class Highscore extends Activity
  {
  TextView name1,name2,name3,name4,name5,score1,score2,score3,score4,score5;
  DBAdapter db1;
  Cursor c;
  int id;
  String n1,n2,n3,n4,n5;
  String s1,s2,s3,s4,s5;
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.highscore);
      Button backbtn=(Button)findViewById(R.id.backbtn);
  
      OnClickListener listener=new OnClickListener() 
      {
          public void onClick(View v) 
          {
              Intent i=new Intent(Highscore.this,MainActivity.class);
              startActivity(i);
              finish();
          }
      };
      backbtn.setOnClickListener(listener);
      id=1;
      name1=(TextView)findViewById(R.id.name1);
      score1=(TextView)findViewById(R.id.score1);
  
  
  
      db1=new DBAdapter(this);
      db1.open();
  
      c=db1.getScore(1);
  
          n1=c.getString(1);
          name1.setText(n1);
          s1=c.getString(2);
          score1.setText(s1);
  
          c=db1.getScore(2);
          n2=c.getString(1);
          name2.setText(n2);
          s2=c.getString(2);
          score2.setText(s2);
  
      c=db1.getScore(3);
          n3=c.getString(1);
          name3.setText(n3);
          s3=c.getString(2);
          score3.setText(s3);
          id++;   
      c=db1.getScore(4);
          n4=c.getString(1);
          name4.setText(n4);
          s4=c.getString(2);
          score4.setText(s4);
          id++;
      c=db1.getScore(5);
          n5=c.getString(1);
          name5.setText(n5);
          s5=c.getString(2);
          score5.setText(s5);
  
      c.deactivate();
      c.close();
      db1.close();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>This time i am only fetching 5 names and scores.</p>
  
  <p>Here's my Logcat Error,</p>
  
  <pre><code>09-19 12:01:36.046: D/AndroidRuntime(455): Shutting down VM
  09-19 12:01:36.046: W/dalvikvm(455): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  09-19 12:01:36.066: E/AndroidRuntime(455): FATAL EXCEPTION: main
  09-19 12:01:36.066: E/AndroidRuntime(455): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.quizapp/com.example.quizapp.Highscore}: java.lang.NullPointerException
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.os.Handler.dispatchMessage(Handler.java:99)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.os.Looper.loop(Looper.java:123)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at java.lang.reflect.Method.invokeNative(Native Method)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at java.lang.reflect.Method.invoke(Method.java:521)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at dalvik.system.NativeStart.main(Native Method)
  09-19 12:01:36.066: E/AndroidRuntime(455): Caused by: java.lang.NullPointerException
  09-19 12:01:36.066: E/AndroidRuntime(455):  at com.example.quizapp.Highscore.onCreate(Highscore.java:59)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  09-19 12:01:36.066: E/AndroidRuntime(455):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  09-19 12:01:36.066: E/AndroidRuntime(455):  ... 11 more
  </code></pre>
  
  <p>If you people are not getting any thing from my question so please ask..
  Please help me to Solve out the Error.</p>
  
  <p>Thanks in Advance</p>