4

I'm facing some issue with app uninstall from the device. The related database seems to not being deleted so I'm unable to update my table and add new column. What can be the problem.

Android version is 6.0.

Aram
  • 331
  • 2
  • 15
  • 1
    You can update the whole database by the following link: http://stackoverflow.com/questions/8133597/android-upgrading-db-version-and-adding-new-table – Jintin Dec 01 '15 at 07:35
  • So one more question. Can I return back to the version 1 after testing done? – Aram Dec 01 '15 at 07:46
  • I think you can't, but I'm not tested. You can keep increase the version. – Jintin Dec 01 '15 at 07:53

3 Answers3

2

To remove the database when the app uninstall in android6... Adds in the AndroidManifest the follow tags:

<application 
    android:allowBackup="false" 
    tools:replace="android:allowBackup">
idelcano
  • 113
  • 7
1

If you want any update reflects in ur existing database , then no need to delete or drop it manually . sqlite provides onUpgrade() for that . you can find lots of good stackoverflow solution ,just google on it how onUpgrade() used .

you can use that like 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);
    }
}  
Radhey
  • 2,139
  • 2
  • 24
  • 42
1

Uninstalling only removes the files in data/data/YOUR_PACKAGE.

If you are adding .db object by your own, (so do not implement Content Provider) and put the db object another directory it wont be deleted.

Also you can use onUpgrade() method.

aleksandrbel
  • 1,422
  • 3
  • 20
  • 38
Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30