简体   繁体   中英

Sqlite Database Still Exists Even I Clear Data and Delete the App from 6.0.1 Device

My db implementation is something like this

public class DbHelper extends SQLiteOpenHelper {

    private static DbHelper mDbHelper;
    private Context context;

    public static synchronized DbHelper getInstance(Context context) {
        if (mDbHelper == null) {
            checkDataBase(context);
            mDbHelper = new DbHelper(context.getApplicationContext());
            Log.d(log, context.getDatabasePath(DB_NAME).getPath());
        }

        return mDbHelper;
    }

    public DbHelper(Context context) {
        super(context, DB_NAME, null, version);
        this.context = context;
    }
}

I put some initial data on onCreate method from an excel file. When I install my app from Android Studio after I cleared data and deleted the app, I behaves like there is a database and never calls onCreate method. It also brings my old data from the old excel file. DB must be deleted when I clear the data.

I log the path in Logcat and it says: /data/user/0/com.mypackage.app/databases/dbname

I think there is a cache holding the database alive somewhere in my device. It occurs only on my 6.0.1 device. It works fine on 5.1.1

Any advices to delete the database?

I had the same problem too, and it bothered me for an entire day.

Uninstall the app then restart the phone. That solves the problem on Marshmellow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM