Persistence Followup

Here's a diagram illustrating the mechanics of TinyWebDB.



Your app can store values persistently by calling the StoreValue function with a key and value as parameters. For example, in a voting app, you might call:

TinyWebDB.StoreValue("David","Obama")

to record the fact that David's vote is for Obama.

Your app can access previously recorded data by calling the GetValue function and providing a key. For example, you might make calls like the following:

TinyWebDB.GetValue("David")
TinyWebDB.GetValue("Joe")

The GetValue function is just a request. It won't directly return a value to your app. Instead, when the server returns the value, a GotValue event is triggered. Your app can set up an event handler to respond to this event.

GotValue returns a value of length 0 if there was no key for a request. So if "Joe" hasn't voted, there will be no entry in the database with key "Joe", and the value returned will have a length of 0. You can test for such an occurrence with blocks like the following (:


Text Group App: Worksheet

Write an App like FrontLine SMS that:
1. Stores a list of phone numbers.
2. Allows an administrator (user) to
  • add numbers to the list
  • view the numbers in the list
  • remove numbers from the list
3. Allows the administrator of the app. to send a text to entire list.
4. Allows all in list to broadcast a text to the list by sending a normal text to the phone where the app resides.
5. Though FrontLine SMS doesn't do this, the app could also post all messages to a twitter account.

Here's the designer window for a very rudimentary user interface for the administrator. Note that there are also non-visible TinyWebDB and Texting components:

1. The app needs to store the numbers persistently using TinyWebDB. Determine a format for the data-- what key will you assign to each number?
2. When the app begins, you'll need to grab the numbers from the database and put them into a list variable. You'll also want to show the numbers in the GroupList label. Sketch out an event-handler for TinyWebDB.Initialize and for TinyWebDB.GotValue.
3. Sketch out an event-handler for the Text Group Button click event. Note that this should text a list and not deal with TinyWebDB at all.
4. Sketch the event-handler for when a new number is added to the list of numbers. This event-handler should modify the list variable and modify the database.

© AppInventor.org 2012