主要原因是:
当调用getWritableDatabase/getReadableDatabase时,onCreate只有在数据库第一次创建时调用,如果数据库存在,则直接返回相应的引用。
参考官方说明:
public abstract void onCreate (SQLiteDatabase db)
Since:
API Level 1
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen.
Parameters
db | The database. |
---|
在模拟器中调试时,通过DDMS的File Explorer功能找到相应的/data/data/your_pakcage下的databases目录,删除掉数据库文件即可。