I am filling some fields and three of those I want to use for displaying the listview with image and details.
I use two tinydbs to be able to save the same fields while at the same time creating the listview, but cannot figure out how to delete an item from both tinydbs.
because it's the only way I figured out I could display the listview with the image. If there is a simpler way please share. And I call this procedure to display all my items in the listview
I don't know about namespaces and how they are used. I didn't use them.
However, I save two different lists with two different tags. One comes from an input box and the other is given a tag name. I am sure I am doing something wrong at that stage because my allelementslist gets initialized every time when in fact it should contain whatever was already in the list.
It took me sometime but this is the way to do it.
I have an edit button and a delete button and this worked
PS...well not exactly. If I have for example 5 entries and I delete the 2nd and then try to delete or update the 5th I get the error
Remove list item: Attempt to remove item 5 of a list of length 4.
Something is wrong with my index that I use to remove the item from the list. because index is the position of the item in the list, if a previous position is deleted all the others get moved.
and I have to use Listview1.SelectionIndex to correct that
No, you are right of course. Both have the same namespace TinyDB1. I just didn't know how to find it and thought it was the same as the name. But I solved my edit and delete problem using the way I show in my answer to Patryk_F.
As I expected, the fact that I am setting my allelements list to an empty list causes a problem when I update my app on the phone. Although the items in the list are shown in the listview when the app starts, I cannot delete them or update them because the index seems to be lost. And if I add a new Item (with a new tag), the previous items no longer appear in the listview, but if I try to create a new item with an existing tag (that is not shown in the listview), I get an error about "Attempt to remove item 0 of an empty list".
So, how to keep the index, after an application update?
PS I don't know if I should create a new topic?
It's a mixup with the index number, and I think it's because I initialize the list to an empty list.
When the app starts after the update the old receipts show up, but as soon as I create a new one the old ones disappear.
But before updating the app, I had one with number 1. So if I try to create a new number 1 I get the following "error", even though number 1 doesnot appear in my list (listview)
Because if I allow it to replace, it replaces one from the list that its index number matches, and changes its number. So if receipt number 1 had index one and now receipt number 100 has index number 1, receipt number 100 changes to receipt number 1.
I think I have to change something so that it is not dependent on neither the tag nor the index.
Your problems with index numbers would go away if you assign unique identifiers to your receipts, perhaps the yyyyMMDDhhmmss timestamp of when you hit the Enter button to create that receipt.
Include unique identifiers (position-independent) in your Elements to help you refer back to the original item in its permanent storage.
I like YAML format for my Elements, to help me reconstruct data from Selections.
It is important to use informative variable names, tags, and keys, to know what you are dealing with in your code.
These are bad names, because of their ambiguity:
index
allelements
tinydb2
TagTextbox1
Notifier2
AmountTXT2
Tag2
...
Tag7
ListView1
this started out as a test app, i am quite new to app inventor, that's why I didn't bother with naming. I did small parts and moved on to get to this. I will make sure to use better naming in a more final version.
I will try to figure out how you suggested I use the index.