Demonstration app for using FirebaseDB in AppInventor

FirebaseDB provides for sharing between users all running the exact same app on their device. Read “What is FirebaseDB?” to learn more about FirebaseDB and what it does for your applications.

This is a quick and very short app that demonstrates the fundamental operation of FirebaseDB when used in MIT App Inventor. I hope to create a more interesting demo app a bit later.

Caution: FirebaseDB is an experimental component offered by MIT App Inventor. FirebaseDB remains under development and is subject to change; apps written today might not work in the future. Apps containing the FirebaseDB component will not work in the emulator – run on your phone or tablet instead. At this time, the cloud-based database is a shared database, shared among multiple users, and cannot – yet – be linked to your personal Google account.

FirebaseDB is Similar to TinyWebDB

The programming interface for FirebaseDB is nearly the same as that used for TinyWebDBTinyWebDB is a simple cloud-based database – to use, you need to set up the TinyWebDB on your own server or on Google’s servers. With your data stored in the “cloud”, your data may be shared among many apps. For the FirebaseDB demo, you do not need to set up your own server, nor do you need to use TinyWebDB:

For details on setting up and using TinyWebDB – including some tricks that enable sharing of TinyWebDB data between apps – please see my book,

  • App Inventor 2 Databases and Files (Volume 3 e-book)
    Step-by-step TinyDB, TinyWebDB, Fusion Tables and Files
    Buy from: Amazon, Google Books, Kobo Books

For more information, including a sample chapter, please see my App Inventor books page.

Sample App User Interface

Our simple demonstration app stores and retrieves a text value to and from the FirebaseDB. As with TinyDB or TinyWebDB, enter a “tag” value to use to look up the value. For example, a tag value could be a part number, and the value could be the text description of the part’s name. Or the tag could be a phone number and the value could be the name of the person who has that phone number.

Screenshot_20160815-152608

The program is operated by entering a tag and a value and then pressing the Store Value button. The value entered is written to the FirebaseDB database in the cloud.

After a value has been stored, you retrieve values by entering the original tag and pressing Retrieve Value. The data corresponding to the tag is retrieved from FirebaseDB and display in the Value field, on screen.

If the app is run simultaneously on other devices, any data updates made on the other devices result in all devices receiving a data changed notification. When the data in the FirebaseDB is changed, the new data is displayed on all devices.

Designer View

A combination of vertical and horizontal layouts is used to organize the positions of the controls (see the Components list, below, or download the sample code).

Store Value and Retrieve Value are buttons. Tag and Value are labels, followed by text boxes for data entry.  Data Changed Event and the status message are both labels.

Drag the FirebaseDB component from the Experimental section of the Designer controls palette. You will receive a warning that FirebaseDB is experimental.

FirebaseDesigner

FBDemo_Components

Blocks View

(Sorry for the image quality on these three blocks – the screen capture utility I used for these did not do a very good job)

The btnStoreValue event handler reads the enter tag and data value from the text boxes on screen, and then stores those to the FirebaseDB. Find the FirebaseDB StoreValue component by clicking on the FirebaseDB component in the Blocks list.

FirebaseBlocks1

Fetching a store value is simple – call FirebaseDB’s GetValue method and pass to it the tag. Unlike TinyDB (but similar to TinyWebDB), the value is not read instantaneously but instead, once the data is read and available, an event called GotValue occurs.  A GotValue event handler processed the incoming data; in our simple app, the data is stored back in to the Value text box, on screen.

FirebaseBlocks2

A unique feature of FirebaseDB is the database’s ability to alert apps that data inside the database has been changed. This alert caused a DataChanged event to occur – and which delivers the tag and value that were updated to the app.

FirebaseBlocks3

Reminder

FirebaseDB is experimental and incomplete, is subject to change, and should not be relied upon at this time for production code. However, you may use it for learning and experimentation.

Download Source Code

Download: FirebaseDB_Demo.aia

After downloading to your computer, you may upload the file to your App Inventor account using Projects | Import project (.aia) from my computer

Related Tutorials

 

9 thoughts on “Demonstration app for using FirebaseDB in AppInventor”

  1. Hi, my name is Özkan , i am from İzmir in Turkey. I like using app inventor, i use it for 2 months.
    I know this is not about this post, but i have a question about the future of android. I have read an article that samsung will use its own OS, named Tizen, in its tablets and phones. Does it mean that android loses its ground and importance. Thanks…

    1. Hi Özkan,

      Very good question!

      Today, the two predominant non PC device operating systems are
      Android
      Apple’s iOS

      Windows Phone has largely disappeared; we now have a universal Windows OS that runs on many devices.

      Tizen has a heritage that goes back to Linux, Intels’ Moblin, Nokia’s Maemo and the open source MeeGo operating systems. When Nokia selected Windows Phone OS, Nokia ended the Mameo project.

      Tizen OS development is supported by Samsung and Intel. Tizen has been around for several years but has not yet taken off in the market. Tizen looks a lot like Android, from a user perspective, but it natively supports HTML5 apps. HTML5 apps can run across many types of devices and operating systems – write once, run anywhere.

      Tizen OS, if successful, does not mean that Android is going away. Instead, it means there is a new OS for an expanding number of devices in the future.

      Just as Apple has their own OS, it seems possible that Samsung could also have their own Tizen OS.

      You can learn more about Tizen at https://www.tizen.org/

      Ed

      1. it means we can not see android in samsung brands that are sold so many, i guess most of the developers will shift the htm5 mobile app. development because this encourages other mobile brands, like LG and lenovo etc, develop its own OS. Thanks for your reply….

Comments are closed.