Noob Q2: How to delete CBL database?

If I have a CBL db already synced on the device, how do I delete that so that I can start the sync over? One might need to get different data (new user? new locale? etc.).

I tried stopping replication and deleting the database. But have not figured out how to remove the local storage so it can start over fresh.

To delete database, use this API. The said, I am not sure I understand the use case. Why do you want to delete a database after every sync ? You should never really have to delete database - that defeats the purpose of having an offline-first store.
Is this for testing purposes where you want to start with a clean slate ?

So while it is true that I want to test things at this moment (e.g. time the initial sync, etc.), I also think I have a need for it in the final app.

Suppose I have two stores, each has inventory. I would imagine 99% of the time the handheld stays at the store it was assigned to. So we have a channel for store1 and a channel for store2. In the rare instance where someone moves the handheld to the other store, you need to wipe out the documents on the handheld and sync to associate it with the new store’s data.

I must be using the API inappropriately, because it doesn’t seem to delete the documents.

    findViewById( View.OnClickListener() {
            public void onClick(View view) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        if (replicator!= null) {
                        replicator = null;
                        if (database != null) {
                            try {
//                                database.close();
                                database = null;
                            } catch (CouchbaseLiteException e) {
                                System.err.println("Failed to close Database: "+ e.getMessage());
                                // TODO: error handling

You can do that without having to delete documents or database. The couchbase lite maintains separate checkpoint doc for each sync gateway it connects to. So when you switch Sync gateway endpoints , it will pull the docs from the new store.

  1. Do you need the handheld to retain the documents from previous store after the move?
  2. If you don’t expect to query across stores and the store docs are independent of each other, then just have a separate couchbase lite instance for each store and switch between the two as needed .

Also, you said that it doesn’t work. You will have to share error output that lead you to the conclusion.

The code looks OK. What happens? Have you used a debugger to verify that the database.delete() call is actually reached?

In your use case it does seem to make sense to delete the database to free up room, if each store has a disjoint set of documents associated with it.

I went back and the delete API is working as designed. I’m not sure why my last attempt didn’t show it.

My apologies and thanks,