BTree Extras | |||||
Home | Read Only Sample Application | J2ME MIDP Sample Application | J2ME Palm Sample Application | Other Products |
A number of sample applications are provided with this distribution which illustrate the functionality of the BTrees supplied for use with Suns J2ME Java implementation. The following applications are supplied - (click on links to see further documentation) -
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 1.0.3. (The application has also been successfully (but not exhaustively) tested with the Version 2.0 beta 1).
The demo applications use the sample BTrees provided - the demo program will handle the non-existence of the sample database by creating a copy of the sample in local memory. 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 screen will then look like this -
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 (by clicking them once with the mouse) to move to the 'View record' option.
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. 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.
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.
To activate this option we need to click on the select button (the dot which is centrally placed between the four arrows on the navigation button).
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 at the bottom right of the screen.
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'.
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 (on the bottom right of the screen) to go on to the next screen (where you will add the value to be associated with this key) or the 'Back' button (on the bottom left of the screen) 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 (on the bottom right of the screen) will add the data to the BTree. Pressing the 'Back' button (on the bottom left of the screen) 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.
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 (on the bottom right of the screen) will delete the data from the BTree. Pressing the 'Back' button (on the bottom left of the screen) 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 (on the bottom left of the screen) which will return you to the main menu.