SQLite database on Android - how to remove it?

Viewed 402

I'm using SQLite database for caching. I want to remove this database on my phone, because I have multiple app versions on which I'm working at and some has different database versions. This is causing exception:

Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 7 to 5

I need to remove whole db file on my phone and create it again with older version.

How to access this file and delete it? I should be stored in data folder but I cant see that folder in my phone storage.

2 Answers

At development time, you can just clear your app's data to delete its databases (and other files). You can clear the data in Android device app settings; accessing that depends on device model and platform version. In recent stock Android versions you can do it e.g. by long-pressing on the app icon in launcher -> app info -> storage -> clear storage.

I was able to remove it from adb shell in Android Studio adb shell run-as com.package.name cd /data/data/com.package.name/ rm -r databases

Related