AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.TinyDB Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.TinyDB:
com.google.appinventor.components.runtime.AndroidNonvisibleComponent com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.Deleteable com.google.appinventor.components.runtime.Component

Public Member Functions

 TinyDB (ComponentContainer container)
 
void Namespace (String namespace)
 
String Namespace ()
 
void StoreValue (final String tag, final Object valueToStore)
 
Object GetValue (final String tag, final Object valueIfTagNotThere)
 
Object GetTags ()
 
void ClearAll ()
 
void ClearTag (final String tag)
 
void onDelete ()
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
HandlesEventDispatching getDispatchDelegate ()
 

Static Public Attributes

static final String DEFAULT_NAMESPACE ="TinyDB1"
 
- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 

Additional Inherited Members

- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
 AndroidNonvisibleComponent (Form form)
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
final Form form
 

Detailed Description

TinyDB is a non-visible component that stores data for an app.

Apps created with App Inventor are initialized each time they run. This means that 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. In contrast, TinyDB is a persistent data store for the app. The data stored in a TinyDB will be available each time the app is run. An example might be a game that saves the high score and retrieves it each time the game is played.

Data items consist of tags and values. To store a data item, you specify the tag it should be stored under. The tag must be a text block, giving the data a name. Subsequently, you can retrieve the data that was stored under a given tag.

You cannot use the TinyDB to pass data between two different apps on the phone, although you can use the TinyDB to share data between the different screens of a multi-screen app.

When you are developing apps using the AI Companion, all the apps using that Companion will share the same TinyDB. That sharing will disappear once the apps are packaged and installed on the phone. During development you should be careful to clear the Companion app's data each time you start working on a new app.

Author
markf.nosp@m.@goo.nosp@m.gle.c.nosp@m.om (Mark Friedman)

Definition at line 80 of file TinyDB.java.

Constructor & Destructor Documentation

◆ TinyDB()

com.google.appinventor.components.runtime.TinyDB.TinyDB ( ComponentContainer  container)

Creates a new TinyDB component.

Parameters
containerthe Form that this component is contained in.

Definition at line 95 of file TinyDB.java.

Member Function Documentation

◆ ClearAll()

void com.google.appinventor.components.runtime.TinyDB.ClearAll ( )

Clear the entire data store.

Definition at line 186 of file TinyDB.java.

◆ ClearTag()

void com.google.appinventor.components.runtime.TinyDB.ClearTag ( final String  tag)

Clear the entry with the given tag{:.text.block}.

Parameters
tagThe tag to remove.

Definition at line 198 of file TinyDB.java.

◆ GetTags()

Object com.google.appinventor.components.runtime.TinyDB.GetTags ( )

Return a list of all the tags in the data store.

Returns
a list of all keys.

Definition at line 172 of file TinyDB.java.

◆ GetValue()

Object com.google.appinventor.components.runtime.TinyDB.GetValue ( final String  tag,
final Object  valueIfTagNotThere 
)

Retrieve the value stored under the given tag{:.text.block}. If there's no such tag, then return valueIfTagNotThere{:.variable.block}.

Parameters
tagThe tag to use
valueIfTagNotThereThe value returned if tag in not in TinyDB
Returns
The value stored under the tag. Can be any type of value (e.g. number, text, boolean or list).

Definition at line 155 of file TinyDB.java.

◆ Namespace() [1/2]

String com.google.appinventor.components.runtime.TinyDB.Namespace ( )

Definition at line 120 of file TinyDB.java.

◆ Namespace() [2/2]

void com.google.appinventor.components.runtime.TinyDB.Namespace ( String  namespace)

Namespace for storing data. All TinyDB components in the same app with the same Namespace property access the same data.

Each Namespace represents a single data store that is shared by the entire app. If you have multiple TinyDB components with the same Namespace within an app, they use the same data store, even if they are on different screens. If you only need one data store for your app, it's not necessary to set a Namespace.

Parameters
namespacethe alternate namespace to use for the TinyDB

Definition at line 114 of file TinyDB.java.

◆ onDelete()

void com.google.appinventor.components.runtime.TinyDB.onDelete ( )

Implements com.google.appinventor.components.runtime.Deleteable.

Definition at line 205 of file TinyDB.java.

◆ StoreValue()

void com.google.appinventor.components.runtime.TinyDB.StoreValue ( final String  tag,
final Object  valueToStore 
)

Store the given valueToStore{:.variable.block} under the given tag{:.text.block}. The storage persists on the phone when the app is restarted.

Parameters
tagThe tag to use
valueToStoreThe value to store. Can be any type of value (e.g. number, text, boolean or list).

Definition at line 134 of file TinyDB.java.

Member Data Documentation

◆ DEFAULT_NAMESPACE

final String com.google.appinventor.components.runtime.TinyDB.DEFAULT_NAMESPACE ="TinyDB1"
static

Definition at line 82 of file TinyDB.java.


The documentation for this class was generated from the following file: