Virtual Machinery logo BTree
Home BTree Guide BTree Performance Sample Applications BTree Roadmap Other Products
BTree ME Sample Application


BTree Demo using Wireless Toolkit

This documentation is supplied as an example of the functionality available with the full distribution. The BTreeDemo sample application class supplied with the Java implementation of the BTreeME illustrates the basic access methods provided. The demo allows you to add , view and delete data from a BTreeME. On exiting from the screen (provided you use the exit bar at the bottom of the screen) your data will be saved if you are connected to a host system via a socket connection and there is a program at the other end of the socket connection which will write the BTree back on to the host system - such a program is supplied as part of the distribution.

The sample application requires the installation of the J2ME Wireless toolkit version 2.1.

Starting the application

When the application first starts you will see the launch screen shown above. Press the 'Launch' button at the bottom right hand side of the screen. The main menu now appears offering three possible options - View record, Add record and Delete record.You can exit the main menu at any time by pressing the 'Exit' button on the bottom left of the screen.

Since we already have some data in the BTree (either loaded from the external sample BTree or created on the device) we can use the up and down arrows on the phone screen to move to the 'View record' option.


Viewing a record

To activate this option we need to click on the 'select' button on the devise

You can now enter the key for the piece of data that you want to show. You are prompted with a phone text entry box. Use the phones buttons to enter the text. In this case we have entered the text 'BOB'. ***Note - the screen may expand to allow entry. When you are finished entering text you can reduce the text box by pressing the select button***. Then press the 'Show' key.

The data associated with this key will then be displayed in a text box on the next screen. As you can see the data associated with this key is 'DYLAN'. After you have viewed the data press the 'Back' key on the bottom left of the screen and you will be returned to the main menu. The other keys you can enter are 'ANGIE', 'KURT', 'STEVIE', 'TINA', 'TOM' and 'TROY'. If you are connected to the HTTPTree test BTree you will also be able to access 'HTTP' and if you are connected to the SOCKETTree test BTree you will also be able to access 'SOCKET'.


Adding a record

We can add our own data to the BTree - use the down arrow on the phone screen (by clicking it once with the mouse) to move to the 'Add record' option.

You should now enter the text of the key that you wish to add to the BTree. We have used the key 'KEVIN'. Press the 'Next' button to go on to the next screen (where you will add the value to be associated with this key) or the 'Back' button to return to the main menu. Pressing the 'Back' button at this point will mean that the data will not be added.

The next screen allows you to add the text to be associated with the key entered in the previous screen. It behaves the same as the previous screen. In this case we are associating the text 'SPACEY' with the key 'TOM' entered previously. Pressing the 'Add' button will return you to the main menu. Pressing the 'Back' button at this point will mean that the data will not be added.

A screen will now appear confirming that the data has been added. Your only option is to press the 'Back' button (on the bottom left of the screen) which will return you to the main menu.


Deleting a record

You can now use the down arrow to select the 'Delete record' option and the central select button to delete a record.

You are now prompted with a phone text entry box. Use the phones buttons to enter the text. In this case we have entered the text 'KEVIN' - the key of the entry that we added to the BTree. Pressing the 'Delete' button will delete the data from the BTree. Pressing the 'Back' button will return you to the main menu. Pressing the 'Back' button at this point will mean that the data will not be deleted.

A screen will now appear confirming that the data has been deleted. Your only option is to press the 'Back' button which will return you to the main menu.


When you exit from the application the BTree will be saved as long as you have connected via a Socket connection and the other end of the socket connection is saving the data to a file. See here for details. Note that if you have carefully followed the example above you will have deleted the entry that you added to the BTree. If you want to test the save functionality you will have to add a new entry, exit the application, restart the application and check that the new entry is there.