title: Attempt to invoke virtual method 'void android.widget.TableLayout.addView(android.view.View)' on a null object reference
body: <p>I'm trying to use a table to show students data as the following :</p>
  
  <pre><code>    public class Main5Activity extends AppCompatActivity {
      DataBaseConnection db;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main5);
      setContentView(R.layout.activity_main);
  
      final TableLayout stk = findViewById(R.id.datatable);
      TableRow tbrow0 = new TableRow(this);
      TextView SNo = new TextView(this);
      SNo.setText(" Student NO ");
      SNo.setTextColor(Color.WHITE);
      tbrow0.addView(SNo);
      TextView StudentName = new TextView(this);
      StudentName.setText(" Student Name ");
      StudentName.setTextColor(Color.WHITE);
      tbrow0.addView(StudentName);
      TextView hmewrk = new TextView(this);
      hmewrk.setText(" Homework mark ");
      hmewrk.setTextColor(Color.WHITE);
      TextView orlmrk = new TextView(this);
      orlmrk.setText(" Oral Mark ");
      orlmrk.setTextColor(Color.WHITE);
      TextView ttlwrkmrk = new TextView(this);
      ttlwrkmrk.setText(" Total Works Mark");
      ttlwrkmrk.setTextColor(Color.WHITE);
      TextView orlexm = new TextView(this);
      orlexm.setText(" Oral Exam");
      orlexm.setTextColor(Color.WHITE);
      TextView exm = new TextView(this);
      exm.setText(" Exam ");
      exm.setTextColor(Color.WHITE);
      TextView exmttl = new TextView(this);
      exmttl.setText(" Exam total");
      exmttl.setTextColor(Color.WHITE);
      TextView textView9 = new TextView(this);
      textView9.setText(" Average");
      textView9.setTextColor(Color.WHITE);
      tbrow0.addView(hmewrk);
      tbrow0.addView(orlexm);
      stk.addView(tbrow0);
      for (String i = db.stdntnmbr();; ) {
  </code></pre>
  
  <p>When calling the students number value from the database to create rows as the same value, it gives me the following error:
  The code is :</p>
  
  <pre><code>public class DataBaseConnection {
  
  private final DataBase dataBase;
  
  DataBaseConnection(Context context) {
      dataBase = new DataBase(context);
  }
  public String stdntnmbr(){
      SQLiteDatabase sqLiteDatabase = dataBase.getWritableDatabase();
      String uid = DataBase.UID;
      Cursor cursor = sqLiteDatabase.query(DataBase.tablename1 , null, uid, null
      , null , null , null , null);
      StringBuilder stringBuilder = new StringBuilder();
      while (cursor.moveToNext()) {
          int studentnmbr = cursor.getInt(1);
          stringBuilder.append(studentnmbr + " " +"+/n");
      }
      return String.valueOf(stringBuilder);   
  </code></pre>
  
  <p>the database type is SQLite and I'm using SQLiteOpenHelper. Any help would be greatly appreciated.</p>