TinyDB – Clear Tags with certain text / prefix

29 Jun

TinyDB is used to store persistent data directly on the Android device; this is useful for highly personalized apps where the user won’t need to share her
data with another device.

You may find yourself using a common prefix for the key. For example, TAG_TOTAL_May2014 or TAG_TOTAL_APR2014. In these cases, the common prefix TAG_TOTAL is used.


Above is a common coding practice used to store related data. For this, you may also find yourself needing to clear ALL data that contain the related data. For example, clearing all data that start (or contain) TAG_TOTAL. To accomplish this, you can use the following:


  • The GetTags, returns a list of all TinyDB tags.
  • The “for each” is used to loop through the list and for each iteration, assigns the next TinyDB tag to the variable item
  • Next the if control statement is used to test and see if the item (database tag) contains the prefix (or the text) that we are looking for.
  • If it does, we use ClearTag to clear or database tag

Looking for AiLiveComplete? See here:

Mobile App Development

1 Comment

Posted by on June 29, 2014 in Uncategorized


One response to “TinyDB – Clear Tags with certain text / prefix

  1. Ali

    May 16, 2018 at 6:36 pm

    Thanks! This helped me solve a problem!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: