Delete specific word in Listview

So i want to delete specific element in list stored in clouddB.
In clicking a button the text in textbox should be deleted from the listview(list in clouddB)

Why not select the item from a listview and then delete it. Saves typing and typing errors, and also avoids the possiblity is the word/text appears more than once....

Can you say how to delete a element of list stored in clouddB

@TIMAI2 sometimes the same elements will be repeating again and again, so when i click the button it should delete all elements specifiied in the textbox.

@TIMAI2 Can you tell in clicking the button how to delete all elements in the list stored in clouddB which is equal to the text in textbox.

Please provide an example of the list items stored in your cloudDB.

![blocks(19)|690x268]

when datadb gotvalue and datachanged :point_up_2:
and append value on clicking a button and more

Deleting individual items from a list held under a CloudDB tag can be tricky.

There are some problems that might occur, if more than one app user is accessing that list at the same time, and they want to delete items from the list.

  • How should the app decide which item the user wants to delete? If he chooses to delete the 4th item of the list, will that be that same 4th item when his delete requests reaches CloudDB? What if some one else has deleted item 3 while that user has been looking at the list copy he received, and deciding he wants to delete the 4th item? Now that formerly 4th item is now the new 3rd item (because list item numbers collapse on item deletion.)

Maybe you can reframe the deletion by content, like saying you want to delete the item "mow the lawn" from a shared to-do list, hopefully because you just mowed the lawn.
To do that, you could add an extra CloudDB component devoted to deleting items from the global Completed list each time a copy of the To Do list arrives from CloudDB through that Deleter component.

If you want, I can describe this technique in further detail.

Yes, can you show an example

This sample shows how to update a shared list, albeit using TinyWebDB, but the concept is similar.

It would take a day for customizing to CloudDB for delete by value, (no promises)

Then can you say how to delete list by the easiest method.

Can you say how to do this method?

Here is how to delete a list item by value, in English, off the top of my head ...


Make a new **DeleteCloudDB** CloudDB component. on the Designer.
Say your list tag in DeleteCloudDB is '**ToDoList**' for this sample.
In the Blocks Editor, init a global to empty list, named 'CloudDBDeleteRequests'

procedure DeleteToDo(**value**)
  add to list global CloudDBDeleteRequests item **value**
  read from **DeleteCloudDB** tag **ToDoList**
end procedure

event when **DeleteCloudDB** gotData (**tag**, **value**)
  while length of list(**CloudDBDeleteRequests**) > 0
      init local **valueToDelete** to select item 1 of global **CloudDBDeleteRequests**
      init local deletion_index to 0
      set **deletion_index**  to index in list(**value**) of **valueToDelete**
      if **deletion_index** > 0 then
         remove index **deletion_index**  from list **value**
         write to **DeleteCloudDB** tag **tag** value **value**
         remove index 1 from global **CloudDBDeleteRequests**
     end if
  end while
end event
1 Like

@ABG Can you show with an aia file🤔

@ABG @ABG Can you pls show this with an example in .aia file

It would be better if you could show in a example in an aia file so, it would be much easier to understand

After sleeping on the problem, I have come to the conclusion that lists stored under single CloudDB tags can't be updated without the possibility of cross-user interference, in general. They might be usable as work queues, with deletion at one end and addition at the other end, but they lack the database attribute known as ACID for reliability.

My sample code I wrote off the top of my head has the same vulnerability to overlapped updates as my prior post on index based updates.

There is hope, however, because the CloudDB component has the http://ai2.appinventor.mit.edu/reference/components/storage.html#CloudDB.GetTagList block and event. We can store the items in our proposed lists as separate tags in CloudDB with a common prefix tag, and filter the GetTagList results by prefix to recover the list we want. Deletion of a single item from such a list could be accomplished by a single CloudDb ClearTag call to the tag for that list and list item, like /TODOLIST/Mow the grass/.

I started to convert my TinyDB project https://docs.google.com/document/d/1GLQJY9q3b8KsEAcfzPEcA-j0zWgyRjTI2Pa792znsBI/edit?usp=sharing
a while ago to CloudDB but lost interest halfway when I ran into the timing differences between TinyDB and CloudDB. The taglist filtering parts can be copied for your use.