Home Windows Apps Phone Apps Bespoke Contact Privacy

professor cad logo

Christopher J Ward
Engineer & Software

Code Snippets

Free code that you can use in your own App Inventor Apps

Create A Folder (Directory)

App Inventor does not provide a function for creating folders, but we can do it using the Canvas Component's ability to save files
The code snippet is a self-contained mini App which you can easily copy to the BackPack and cannibalise to work in your Apps.

 Free Download 

Create Folder

TinyDB: Multiple Namespaces

You could think of a Namespace as being a box. If you have several boxes (Namespaces), it makes sense to store related items in each.
For example: a box for shoes, a box for toys, a box for books and so on.

The code snippet is a self-contained mini App. On Screen1 we populate the TinyDB using 3 Namespaces. On Screen2 we populate a ListView from the TinyDB to prove that both Screens "see" the same TinyDB (ensure the name given to TinyDB is identical on each Screen!).

Note: When using Multiple NameSpaces, the Namespace TextBox in the Properties Palette should be empty - NameSpace names are defined in the Blocks Code. Also note how much of the code on Screen2 is similar to Screen1. This is an alarm bell telling us the code is inefficient! What we should consider instead is to use Virtual Screens.

 Free Download 

Screen1 GUI


Screen1 Blocks


Screen2 GUI


Screen2 Blocks


TinyDB: Backup to External File

You might need to backup your TinyDb data because if, for example, your app is uninstalled or overwritten, TinyDb data will be lost.

The code snippet is a self-contained mini App for you to play with as-is to get an understanding of how Store-Restore of data works. It is necessary to save the file on the virtual SD drive, since it would otherwise be lost in the same scenario that would lose TinyDB.

 Free Download 

Screen1 GUI


Screen1 Blocks