Android – uninstalling the application from the device does not delete the database

I encountered some problems uninstalling the application from the device. The related database does not seem to have been deleted, so I can't update the table and add new columns. What might be the problem

The Android version is 6.0

resolvent:

If you want to reflect any updates in the existing database, you don't need to delete or delete it manually. SQLite provides onupgrade(). You can find many good stackoverflow solutions. Just search Google for the usage of onupgrade()

You can use it this way

@Override
public void onUpgrade(sqliteDatabase db, int oldVersion, int newVersion) {
    switch(oldVersion){
        case 1:
            db.execsql("ALTER TABLE " + DATABASE_TABLE + " ADD COLUMN " + NEW_COLUMN_NAME + TYPE);
    }
}  

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>