My application reads data from EditText, writes to the database (SQLite), and prints the entire database. But when the application is restarted on the Emulator, the database already contains those entries that I added.

So, how do I restart the application, what would it be with a clean database? And is it possible that precisely because of this, the application does not start on the Smartphone (created an apk file, and installed it).

  • When the application terminates, make a DELETE FROM table_name; . - s8am

1 answer 1

Just delete the database before running. And when you initialize the application do this:

 db = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null); db.execSQL("CREATE TABLE IF NOT EXISTS " + TableName + " (Field1 VARCHAR, Field2 VARCHAR;");