I have an android app for my school project that keeps track of the times it is ran by putting in the date in a table in the SQLite database whenever it is ran, and when it is run for the first time, there are supposed to be none in the database so it acts accordingly. When debugging on my phone (installing it fresh), it does so. Problem is when running on emulator, it is not. There's no way that a time entry can be happening when running for the first time so I am assuming that the emulator must have saved the current state when running the app before and not be acting like a fresh install (I am slightly new to android, my partners are even newer). Also, we are using a git repository to install it on their machines to run on an emulator. Is there anyway I can clear this data, and submit it to git so when they run it on their machines, it will act as a fresh install on both their machines?
Clearing database for emulator app so it acts like being run for the first time?
71 views Asked by Matt Southard At
1
When you update an app on an emulator or a device, its old data such as databases are retained. That's what is happening on your emulator.
If you want to make sure the old data is deleted, just uninstall your app in the emulator or device first, and then reinstall.
Database files don't get transferred over git unless you specifically add in code that e.g. copies a database file from assets to the device.
More detailed reading: When is SQLiteOpenHelper onCreate() / onUpgrade() run?