Вопрос

I have subclass of SQLiteOpenHelper with my own implementation of onCreate, since it's required for creating tables. When I run my application in the emulator, I don't see my table to be created (I added a syntax error in the SQL code that is executed by onCreate). Is it not being invoked by design? Can I somehow force emulator to create the table every time the emulator is run? Or do I have to operate through versions? Or maybe I might be missing something for the tables to be created?

Это было полезно?

Решение

onCreate is run only once the database is created for the first time. You need to uninstall your app to make it run again.

onUpgrade is used to upgrade the database to a new version but it's usually to upgrade between release version, not during development. If you're just adding more tables, etc. during development, you can just uninstall your app and install again.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top