title: I get SQLiteException. What can be a problem?
body: <p>I get SQLiteException. Can anyone advise what can be a problem?
  I have provided a code from MainActivity and DatabaseHandler.
  In my program, I add Car objects to the SQLite database and try to get the cars I have added in a Log. But Android Studio says that there is no such table: cars (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM cars</p>
  <pre><code>public class DatabaseHandler extends SQLiteOpenHelper {
  public DatabaseHandler(Context context) {
      super(context, Util.DATABASE_NAME, null, Util.DATABASE_VERSION);
  }
  
  @Override
  public void onCreate(SQLiteDatabase sqLiteDatabase) {
      String CREATE_CARS_TABLE = &quot;CREATE TABLE &quot; + Util.TABLE_NAME + &quot;(&quot;
              + Util.KEY_ID + &quot; INTEGER PRIMARY KEY,&quot;
              + Util.KEY_NAME + &quot; TEXT,&quot;
              + Util.KEY_PRICE + &quot; TEXT&quot; + &quot;)&quot;;
  
      sqLiteDatabase.execSQL(CREATE_CARS_TABLE);
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
      sqLiteDatabase.execSQL(&quot;DROP TABLE IF EXISTS &quot; + Util.TABLE_NAME);
      onCreate(sqLiteDatabase);
  }
  
  public void addCar(Car car) {
      SQLiteDatabase db = this.getWritableDatabase();
  
      ContentValues contentValues = new ContentValues();
      contentValues.put(Util.KEY_NAME, car.getName());
      contentValues.put(Util.KEY_PRICE, car.getPrice());
  
      db.insert(Util.TABLE_NAME, null, contentValues);
      db.close();
  }
  
  public Car getCar(int id) {
      SQLiteDatabase db = this.getReadableDatabase();
  
      Cursor cursor = db.query(Util.TABLE_NAME, new String[] {Util.KEY_ID, Util.KEY_NAME,
                      Util.KEY_PRICE}, Util.KEY_ID + &quot;=?&quot;, new String[] {String.valueOf(id)},
              null, null,
              null, null);
      Car car = new Car();
      if (cursor != null) {
          try {
              cursor.moveToFirst();
              car = new Car(Integer.parseInt(cursor.getString(0)),
                      cursor.getString(1), cursor.getString(2));
          } finally {
              cursor.close();
          }
  
      }
  
      return car;
  }
  
  public List&lt;Car&gt; getAllCars() {
      SQLiteDatabase db = this.getReadableDatabase();
  
      List&lt;Car&gt; carsList = new ArrayList&lt;&gt;();
  
      String selectAllCars = &quot;SELECT * FROM &quot; + Util.TABLE_NAME;
      Cursor cursor = db.rawQuery(selectAllCars, null);
      if (cursor.moveToFirst()) {
          try {
              do {
                  Car car = new Car();
                  car.setId(Integer.parseInt(cursor.getString(0)));
                  car.setName(cursor.getString(1));
                  car.setPrice(cursor.getString(2));
  
                  carsList.add(car);
              } while (cursor.moveToNext());
          } finally {
              cursor.close();
          }
  
      }
  
      return carsList;
  }
  </code></pre>
  <p>}</p>
  <p>Main activity:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      DatabaseHandler databaseHandler = new DatabaseHandler(this);
      databaseHandler.addCar(new Car(&quot;Toyota&quot;, &quot;30 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;Opel&quot;, &quot;25 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;Mercedes&quot;, &quot;50 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;KIA&quot;, &quot;28 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;Mazda&quot;, &quot;30 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;Honda&quot;, &quot;25 000 $&quot;));
      databaseHandler.addCar(new Car(&quot;Skoda&quot;, &quot;50 000 $&quot;));
      //databaseHandler.addCar(new Car(&quot;Hundai&quot;, &quot;28 000 $&quot;));
  
      List&lt;Car&gt; carList = databaseHandler.getAllCars();
  
  
      for (Car car : carList) {
          Log.d(&quot;CarInfo:&quot;, &quot;ID &quot; + car.getId() + &quot;, name &quot; + car.getName() +
                  &quot;, price &quot; + car.getPrice());
      }
  
  }
  </code></pre>
  <p>}</p>
  <p>Exception in the following line:
  Cursor cursor = db.rawQuery(selectAllCars, null);</p>
  <pre><code>     Caused by: android.database.sqlite.SQLiteException: no such table: cars (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM cars
      at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
      at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
      at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
      at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
      at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:61)
      at android.database.sqlite.SQLiteQuery.&lt;init&gt;(SQLiteQuery.java:37)
      at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
      at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1545)
      at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1484)
      at com.example.carsdb.Data.DatabaseHandler.getAllCars(DatabaseHandler.java:75)
      at com.example.carsdb.MainActivity.onCreate(MainActivity.java:30)
  </code></pre>