0

I used this reference to copy over a database I have:

Using your own SQLite database in Android applications

But when the database is copied over and I remove the database file from my assets folder and run my app it still reads the database. So what I have been doing is renaming the db file and running it again for testing purposes. I don't like this cause I feel its taking up unnecessary space. But I was wondering if I can somehow delete the database that was copied over so I wont have to keep renaming. Anyone know?

Ali
  • 9,800
  • 19
  • 72
  • 152
JoeyL
  • 1,295
  • 7
  • 28
  • 50
  • Add a versioning schema so you know that you've put a new database version and check the version in `checkDataBase` in addition to existance – zapl Aug 30 '12 at 22:58
  • http://stackoverflow.com/questions/9109438/how-to-use-existing-database-with-android-app/9109728#9109728 – Yaqub Ahmad Aug 31 '12 at 07:10

2 Answers2

1

As far as I know you will not be able to delete it, but in this way you can generate a new one with changing the version :

private static class DatabaseHelper extends SQLiteOpenHelper {

       private static final int DATABASE_VERSION = 1; // Increase ==> new empty DB created

        DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }
}

In your code the version is 1, you can increase it and generate a new empty database.

Ali
  • 9,800
  • 19
  • 72
  • 152
0

Try renaming the database in your assets folder, but don't forget to change the name in your DbHelper as well!

corgichu
  • 2,580
  • 3
  • 32
  • 46