10

After deploying my application into android mobile,at starting the database is getting created. I do want to delete database tables in mobile.How to do that in mobile..

1
  • we can't help unless you post your code.
    – Phil
    Commented Dec 21, 2011 at 6:13

3 Answers 3

12

u can delete database manually by clear Data.

settings\applications\manage Applications\'select your application'\clear data.
1
  • 1
    this will delete more than the database. Commented Feb 24, 2018 at 5:43
9

If you use Room Persistence Library, then try to do the following (but maybe it also will work for other libraries, I haven't checked).

In Android Studio open View -> Tool Windows -> Device File Explorer. Then in the Device File Explorer:

  1. Choose your device.
  2. In the file tree navigate to /data/data/{your_package_name}/databases.
  3. Delete files which names match your database name (you give a name to your database when you build RoomDatabase in your code). In my case it's my_app.db.

Here's a screenshot:

Here's a screenshot

2

There is a function to delete DB :

https://developer.android.com/reference/android/content/Context.html#deleteDatabase(java.lang.String)

context.deleteDatabase(dbFileName)

It's that short...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.