title: Insert Column Error (SQLite Android Studio)
body: <p>I keep getting an error where it says no column is created in my database and I'm not sure why. The error below is what I get.</p>
  <p><strong>Error: table scores has no column named score in &quot;INSERT INTO scores(score,scoreName) VALUES (?,?)&quot;
  2021-03-29 19:04:44.590 23125-23125/com.example.assignment3</strong></p>
  <p><strong>E/SQLiteDatabase: Error inserting score=5 scoreName=Michelle</strong></p>
  <p><strong>DatabaseHandler2.java</strong></p>
  <pre><code> public class DatabaseHandler2 extends SQLiteOpenHelper {
      public static final String DATABASE = &quot;scoreDatabase&quot;;
      //tables
      public static final String TABLE_SCORES = &quot;scores&quot;;
      //scores
      public static final String KEY_SID = &quot;scoreID&quot;;
      public static final String KEY_SNAME = &quot;scoreName&quot;;
      public static final String KEY_SCORE = &quot;score&quot;;
  
      public DatabaseHandler2(Context context) {
          super(context, DATABASE, null, 1);
      }
  
      @Override
      public void onCreate(SQLiteDatabase db){
          //Creates Tables
          String CREATE_SCORES_TABLE = &quot;CREATE TABLE &quot; + TABLE_SCORES + &quot; (&quot;
                  + KEY_SID + &quot; INTEGER PRIMARY KEY AUTOINCREMENT, &quot; + KEY_SNAME + &quot; TEXT, &quot; + KEY_SCORE + &quot; INT)&quot;;
          db.execSQL(CREATE_SCORES_TABLE);
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
          db.execSQL(&quot;DROP TABLE IF EXISTS &quot; + TABLE_SCORES);
          onCreate(db);
      }
  
      public void insertScore(String name, int score){
          SQLiteDatabase db = this.getWritableDatabase();
          ContentValues values = new ContentValues();
          values.put(KEY_SNAME, name);
          values.put(KEY_SCORE, score);
  
          db.insert(TABLE_SCORES, null, values);
          db.close();
      }
      public Cursor allScores(){
          SQLiteDatabase db = this.getWritableDatabase();
          return db.rawQuery(&quot;SELECT * FROM &quot; + TABLE_SCORES,null);
      }
  }
  </code></pre>
  <p><strong>Game.java - snip of where DatabaseHandler is used</strong></p>
  <pre><code> public class Game extends AppCompatActivity {
      private int numberCorrect;
  
          @Override
          public void onFinish() {
              answer0Btn.setEnabled(false);
              answer1Btn.setEnabled(false);
              answer2Btn.setEnabled(false);
              answer3Btn.setEnabled(false);
              bottomTxt.setText(&quot;Your score: &quot; + numberCorrect + &quot;/&quot; + (game.getTotalQuestions() - 1));
              playBtn.setText(&quot;Play Again&quot;);
              playBtn.setVisibility(View.VISIBLE);
              DatabaseHandler2 db = new DatabaseHandler2(getApplicationContext());
              db.insertScore(getUsername(), numberCorrect);
          }
      }
  }
  </code></pre>
  <p><strong>Scores.java</strong></p>
  <pre><code> public class Scores extends AppCompatActivity {
      TextView allScoresTxt;
      Game game = new Game();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_scores);
          allScoresTxt = findViewById(R.id.allScoresTxt);
  
          DatabaseHandler2 db = new DatabaseHandler2(getApplicationContext());
          Cursor cursor = db.allScores();
          if (cursor.getCount() == 0) {
              allScoresTxt.setText(&quot;No Data&quot;);
          } else {
              while (cursor.moveToNext()) {
                  allScoresTxt.setText(&quot;Name: &quot; + cursor.getString(0) + &quot;\t Score: &quot; + cursor.getInt(1) + &quot;\n&quot;);
              }
          }
      }
  }
  </code></pre>