Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

New Developer
Posts: 31
Registered: ‎09-20-2013
My Device: Z10
My Carrier: NA

Using javascript in a java application

Hi all,


Hopefully someone out there can help us. My colleague and I are working on a project which has two applications that will be running on Blackberry 6 and 7 devices.


The first application (the main one) is a hybrid GUI which has been written in javascript in Webworks and does most of the work of the project, such as making HTTP POST requests, opening and updating a local database, user interaction, etc. The other application is a background application that is written in java in Eclipse that listens for a Push message in JSON format, then sends a POST request for information and updates the database with the response.

The problem we are having is that the database created using javascript in webworks with the openDatabase() function cannot create a database assigned to a fixed directory with a fixed name and there are no other javascript functions that we can find that can do this. These two applications are going to be installed on many devices. This has created a communication problem with the background app as we will not be able to open the database using a fixed path since the name/path of the database may not be the same on each device. We have also found that even if we explicitly state the path of a database on one specific device, the java code in the background app cannot open it as an "error decrypting header blackberry" occurs.

We decided to try and implement javascript code in the background app hoping that we can open the database that way using the net.rim.device.api.script library in eclipse. So far we have only found examples implementing this class using a browser object in java so we are lost how to actually do this in a GUIless app.

So our questions are:

1. Maybe our undertsanding is wrong and the path and name of the database created using the openDatabase() function in javascript is always static and never changes, but if we are right,

2. Is there any function in javascript where we could explicitly state the path of the database, if no,

3. Could someone please help us with a small example of how to implement a javascript call in java using the net.rim.device.api.script library.

4. If we do implement this using javascript in java, will we be able to open the database or will we still have a problem as the path created in this background app is different from the path created in the GUI.

If anyone could help us out it would be greatly appreciated!

Thank you all for your time,



Posts: 101
Registered: ‎07-26-2013
My Device: BB 10
My Carrier: All Carriers

Re: Using javascript in a java application


    You want to use database and you are trying JavaScript for it. Why can;t you use XML for storing the data?

Hit Like if this post found useful
New Developer
Posts: 31
Registered: ‎09-20-2013
My Device: Z10
My Carrier: NA

Re: Using javascript in a java application

Thanks for the reply, 


It's a good idea but the problem is that the data is we are storing is quite large so an xml file was impractical when we designed the application.