Explore AppyBuilder logo
  • Home
  • Forum ▾
  • Reference ▾
  • Facebook ▾

Storage - AppyBuilder for Android

Table of Contents

  • FusionTablesControl
  • TinyDB
  • TinyWebDB

FusiontablesControl

Picture of Fusion Tables component

Google Fusion Tables lets you store, share, query and visualize data tables; this component lets you query, create, and modify these tables, using the Fusion Tables API V2.0.

To use the component, define a query, call SendQuery to execute the query, and GotResult will hand you the result when it is ready.

Note that you do not need to worry about UTF-encoding the query. But you do need to make sure the query follows the syntax described in the reference manual, which means that things like capitalization for names of columns matters, and that single quotes must be used around column names if there are spaces in them.

The results of the query will generally be returned in comma-separated values (CSV) format, and can be converted to list format using the "list from csv table" or "list from csv row" blocks.

Using the FusiontablesControl Component

Getting an API Key

In order to use the FusiontablesControl Component you need to acquire a Google a Google Applications Programming Interface (API) key, an API Key. To get an API key, follow these instructions:

  1. Go to your Google APIs Console and login if necessary.
  2. Select the Services item from the menu on the left.
  3. Choose the Fusion Tables service from the list provided and turn it on.
  4. Go back to the main menu and select the API Access item.

Your API Key will be at the bottom of that pane in the section called "Simple API Access". You will provide your key as the value to the ApiKey property in all your Fusiontables apps.

Creating Fusion Tables

You will probably want to create your own Fusion Tables to experiment with as you are developing your apps. This is as easy as creating a Google document, if you are familiar with that process. Here are the steps:

  1. On the web, login to your Gmail account or any other Google service (e.g., Drive, YouTube).
  2. Select the More > Even more menu and scroll to the bottom of the page of Google services where you will find the Fusion Tables service.
  3. You may want to view some of the examples and work through a tutorial to learn the basics.
  4. Click the See my tables button (top right of the page). This will bring you to your own page.
  5. You should see a list of your own tables or tables that have been shared with you (possibly none).
  6. Use the Create button to create a new table. Give it some column names. And save it.
  7. Click on the Share button (top right) to modify the table's permissions.

Creating a Fusiontables App

When you drag the FusiontablesControl component onto the Designer, don't forget to set its ApiKey property, which is initially blank. You should copy this from your Google APIs Console and paste it into the property field.

Properties

ApiKey : text (read-only)

Copy and paste your Google API key into this property.

In order to develop apps that use Fusiontables, you must obtain a Google API Key. To get a key follow these instructions.

  1. Go to your Google APIs Console and login if necessary.
  2. Select the Services item from the menu on the left.
  3. Choose the Fusiontables service from the list provided and turn it on.
  4. Go back to the main menu and select the API Access item.
Your API Key will be near the bottom of that pane in the section called "Simple API Access".
Query : text (read-only)
The query to send to the Fusion Tables API.

For legal query formats and examples, see the Fusion Tables API V2.0 reference manual.

Note that you do not need to worry about encoding the query, but you do have to make sure it follows the syntax described in the reference manual, which means that things like capitalization for names of columns matters, and that single quotes need to be used around column names that contain.

Events

GotResult(text result)
Indicates that the Fusion Tables query has finished processing, with a result. The result of the query will generally be returned in CSV format, and can be converted to list format using the "list from csv table" or "list from csv row" blocks.

Methods

SendQuery()
Send the query to the Fusion Tables server.
ForgetLogin()
Discards the user's account name, forcing them to re-authenticate when accessing a Fusion Table.

TinyDB

Picture of TinyDB component

Use a TinyDB component to store data that will be available each time the app runs.

TinyDB is a non-visible component.

Apps created with AppyBuilder are initialized each time they run. If an app sets the value of a variable and the user then quits the app, the value of that variable will not be remembered the next time the app is run. TinyDB is a persistent data store for the app, that is, the data stored there will be available each time the app is run. An example might be a game that saved the high score, and retrieved it each time the game is played.

Data items are stored under tags . To store a data item, you specify the tag it should be stored under. Subsequently, you can retrieve the data item that was stored under a given tag. If there is no value stored under a tag, then the value returned is the empty text. Consequently, to see if a tag has a value stored under it, test whether the return value is equal to the empty text (i.e., a text box with no text filled in).

There is only one data store per app. If you have multiple TinyDB components, they will use the same data store. To get the effect of separate stores, use different keys. Also each app has its own data store. You cannot use TinyDB to pass data between two different apps on the phone.

Properties

none

Events

none

Methods

ClearAll()
Clear the entire data store
ClearTag(text tag)
Clear entry with given tag
any GetTags()
Get all the tags in the data store
GetValue(text tag)
Gets the value that was stored under the given tag. If no value
StoreValue(text tag, valueToStore)
Store the value under the given tag. The tag must be a text string; the value can be a string or a list.
was stored, returns the empty text.

To clear out the data base for an app, go on the phone under Settings → Applications → Manage Applications, the pick the app, and press "Clear Data".

The data in TinyDB is persistent only when you have packaged and downloading your app. If you are developing connected to the phone, and you restart the Appinventor application, or if you disconnect and reconnect the phone, then the data base will start fresh. This is a case where the application is not merely being stopped and restarted; it is being removed from the phone and then reloaded.

TinyWebDB

Picture of Tiny Web Database component

Non-visible component that communicates with a Web service to store and retrieve information.

See Creating a Custom TinyWebDB Service.

Properties

ServiceURL

Events

GotValue(text tagFromWebDB, any valueFromWebDB)
Indicates that a GetValue server request has succeeded.
ValueStored()
Event indicating that a StoreValue server request has succeeded.
WebServiceError(text message)
Indicates that the communication with the Web service signaled an error

Methods

GetValue(text tag)
GetValue asks the Web service to get the value stored under the given tag. It is up to the Web service what to return if there is no value stored under the tag. This component just accepts whatever is returned.
StoreValue(text tag, any valueToStore)
Asks the Web service to store the given value under the given tag

© 2014-2016 AppyBuilder

Contact Us