Jan 20

Working with WebSQL in an HTML5 mobile app

I wrote some days ago that I now work on a BlackBerry 10 app using BlackBerry WebWorks, which is basically Apache Cordova (Phonegap).

The app needs to read data from JSON sources and store it locally, so that the app works offline. So I need local storage, and although the WebSQL specification came to an end, it’s supported in WebWorks, Chrome and other platforms.

Working with WebSQL is relatively straightforward because in the end it’s the well known SQLite in the backend. But, you have to deal with callbacks. For example, to write stuff you’re using this kind of code:

// size in bytes, for example 1024*1024*1
// params may be an array of data for the sql statement
var size = 1024*1024*1;
var db = openDatabase("mydb", '1.0', "mydb", size);
var f = function(tx) {
  tx.executeSql(sql, params, function(transaction, result) {
	// success, do something with the result
  }, function(tx, e) {
     // failure, error is in e.message

So there are two callbacks, one in case of success and one in case of error. If you want to execute multiple statements at once, you can put them all into one transaction. In that case you have to do some work to handle the results and errors. Something like this:

f = function(tx) {
	var hasError = false;
	var errors = [];
	var results = [];
	_.each(sql, function(singlesql) {
		tx.executeSql(singlesql, params, function(transaction, result) {
		}, function(tx, e) {
			// failure
			hasError = true;
	// do something with the result

(Note: _.each() is a method of underscore.js framework.)

Unfortunately this does not work reliable. Do you spot the error?

The function iterates though an array of sql statements, and each statement is being executed and in the result callback the result of that statement is added to a result array.

But what happens if you want to use the result array right after the _.each() loop? You’re using the result array before all the callbacks from the sql statements has been executed! So it may be null or contains only some entries, but not all.

You need to work on the results only when all sql statements have been executed:

f = function(tx) {
	var hasError = false;
	var errors = [];
	var results = [];
	var len = sql.length;
	for (var i = 0; i < len; i++) {
		tx.executeSql(sql[i], params, function(transaction, result) {
			if (i == (len-1)) {
				// do something with the result HERE!
		}, function(tx, e) {
			// failure
			hasError = true;

In a real world app that may get cumbersome when you do lot of work with WebSQL. Therefore I started to write a framework, just like I always do when things get complicated 🙂

What about this code:

b = new JBUDatabase("mydb");
// create table if it does not exist yet
db.createTable("tickets", [ {
	name : 'id',
	type : 'TEXT'
}, {
	name : 'title',
	type : 'TEXT'
} ]);
// create a demo array of data for 100 tickets
var data = [];
for (var i = 1; i < 100; i++) {
	data.push(["ID "+i,"ticket title "+i])
// write the data to the WebSQL database
db.writeEntries("tickets", data);

All the WebSQL stuff packaged in a simple to use API. Much more clear, isn't it?

Jan 14

News about BlackBerry 10 development

Some weeks ago I wrote about my efforts do build a BlackBerry 10 app with DominoToGo and Titanium.

I made progress with the app since then. I can synchronize data from IBM Domino using DominoToGo, I can display the data in views and forms. So is everything good?

Unfortunately: no.

During the work on this Titanium based BlackBerry 10 app I discovered several features that were unstable, and I discovered a lot of Titanium features that are simply not implemented for BlackBerry 10. Furthermore, there is no word from Appcelerator that they will continue to support BlackBerry 10 (although there is no word against that, too).

In the end, working on that app felt more and more like riding a dead horse. So my customer and I made a decision: move away from Titanium for this BlackBerry 10 app (while staying with Titanium for another complex, iOS based app).

It’s a tough decision since time is pressing. But what’s an app without future and with potential stability problems good for?

Now I’m re-implementing the app with BlackBerry WebWorks, which is an enhanced Apache Cordova (Phonegap) version for BlackBerry. So basically I’m developing HTML5 now.

One bad thing about mobile development with HTML5 is how to style the app so that it looks and feels like a native app. Yes, there are apps where users accept that they look different, but in most cases users like it when the app looks and feels the way they know.

I looked at Sencha, Dojo mobile, jQuery mobile etc. But for BlackBerry, they all didn’t convinced me. The solution seems to be bbUI.js. That framework not only does a good job in providing UI controls, but delivers an easy to use screen architecture, too. Each screen is simply an HTML file with a special DIV as root element.

Furthermore, each screen can use it’s own JavaScript resources. That way, I can separate UI from logic similar to Titanium’s model-view-controller architecture.

In addition I’m using underscore.js, Backbone.js and the core of jQuery.

I still don’t like Cordova’s way of using callbacks in callbacks in callbacks in callbacks. It’s hard to write clean, readable code when you’re forced to deal with so many callbacks. I understand why they chose this architecture, nevertheless, using too many callbacks lead to code that’s hard to understand.

The good part is that I can re-use much code I already wrote in Titanium, so it’s not a start from the beginning. And so far the performance on an old Z10 device is surprisingly good.

Dec 09

That was hard. Problems with BlackBerry deployment fixed by changing “ü” against “u”.

I fought with this issue for a week: when trying to deploy a BlackBerry 10 app to a device, I got this error:

result::failure 500 ‘ascii’ codec can’t decode byte 0xc3 in position 111: ordinal not in range(128)

I posted the issue in the developer forum, asked fellow developers and asked for help in this blog, with no results. Every day I thought about the problem and tried new approaches, without any luck. Today I finally found a way to submit a ticket to a BlackBerry issue tracker, and shortly after en engineer responded. After some exchange of comments and files the issue was found: I used an umlaut in the author name in the debug token’s certificate. The author was set to “Ingenieurbüro Julian Buss”, and the “ü” was the problem. After I changed the author name to “Julian Buss” and recreated the debug token, the deployment ran without any problem.

In my last comment in the issue I suggested to improve the error message in this case. It’s really hard to believe that this issue slipped through quality assurance.

Nevertheless, now I’m able to test my Titanium and DominoToGo BlackBerry app on the device and so far it runs fine!

Dec 05

Anyone with BlackBerry 10 / Momentics IDE experience out there? I cannot deploy a project to a device.

So far my experiences with BlackBerry 10 development is quite mixed. I managed to work around most issues when creating a Blackberry app with Titanium, but now I want to deploy the app to a test device, a BlackBerry Z 10.

And it simply does not work. The process always breaks with a quite cryptic message:

Error in final launch sequence
Cannot prepare and download the binary
result::failure 500 ‘ascii’ codec can’t decode byte 0xc3 in position 111: ordinal not in range(128)

It’s the same when I try to create a blank “Hello World” project in BlackBerry’s native development environment, the Momentics IDE. Here is what I did:

  • downloaded and installed Momentics
  • downloaded and installed API level 10.2 (target device is a Z10)
  • created a new BlackBerry app in Momentics from the most basic “Hello World” template
  • ran deploymend wizard, installed debug token on device
  • device is connected via USB, Momentics shows me a green light for USB
  • clicked “Run”

And again the same error is reported and the app is not deployed on the device. The app does work in the simulator, though.

I learned that such kind of message can occur when one tries to deploy a project compiled for the simulator (x86) to the device (arm). So I looked everywhere to make sure that the project was compiled for arm, and indeed all settings in Momentics are set to arm and not x86.

So far I tried these steps on three different computers, one Windows 7 machine and two Macs. It’s always the same.

I posted the issue to the BlackBerry developer forum, without any useful response so far. Anyone who is doing BlackBerry development and experienced similar issues?


Nov 07

Features I simply love in my BlackBerry Passport

As you might have read I bought a BlackBerry Passport instead of an iPhone 6 (read my first impressions here).

I used the BlackBerry Passport for some days now, although with WLAN only because it takes some days to exchange my MicroSIM card to a NanoSIM. Nevertheless, I already found some features I started loving:

Word suggestions

While typing the Passport suggests three words that it thinks you are going to write. If one word is what I have in mind, I simply wipe on the keyboard from the bottom to the top roughly where the suggested word is displayed. It’s a very small and fast gesture, and it works very, very well for me.

In fact, there are times where I can write half a sentence just by accepting Passport’s suggestions! For example a german sentence like “Können Sie mir bitte das Dokument senden?” would go like this:

  • Type “Ko” – Passport suggests “Können” – I accept this with the wipe gesture.
  • Now Passport already suggests “wir”, “Sie” and “ja” – I accept “Sie” with a gesture.
  • Now Passport suggests “mir”, “sich” and “uns” – I accept “mir”
  • Next suggestions are “ein”, “bitte”, “sagen” – I accept “bitte”
  • Next suggestions are “jemand”, “eine”, “die” – I don’t accept but type “das Do” after which Passport suggests “Dokument”, “Dokumente” and “Dokumentation” – I accept “Dokument”
  • Finally I type “se” for which Passport suggests “senden”, which I accept.

So I wrote “Können Sie mir bitte das Dokument senden” by actually typing 10 letters. Furthermore, Passport learns from the texts I write. For example it now knows the word “XPage”, so when I type “xp” the word “XPage” is suggested.

The very accurate and intelligent word suggestions combined with the simple gestures to accept them combines to a very good flow when writing. If you’re writing a lot of mails and other texts on your mobile device, check this feature on the Passport. It may be reason enough to buy it.

To get an impression have a look at this video and skip to time index 2:00:

Scrolling using the keyboard

I can scroll through websites, mails etc. just by moving my finger across the keyboard. I do not need to wipe on the screen itself, so I always have a clear view of the content displayed on the screen. It feels very natural.

Backberry Hub and Keyboard Shortcuts

All mails are displayed in the BlackBerry Hub, which works very well for me. Mails from different accounts are color coded, and I have the two actions “put in folder” and “remove” just beside every mail. So deleting a mail is done with just one touch. It’s the fastest way I can think of, on iPhone you need to wipe first and then touch. And yes, just after deleting there is an undo button displayed for some seconds.

Furthermore, there are some keyboard shortcuts I can use. For example to compose a new mail in my Gmail account, I simply press “c” and “r”. Much faster than doing multiple touches on the display!

Put upside down to save power, take it to activate the display

If you don’t want to be disturbed and save power, you just need to put the Passport upside down on the table. As an option you can enable that the display is activated automatically when you take the Passport from the table – I enabled that and it’s very cool. No click on the Home button anymore, just take the device and it’s on.

The red blinking LED

If there is a new mail or notification, a red LED blinks – just like it did since the first BlackBerry device. It’s a very discreet way of letting you know that it’s worth take the device and check it. No sound, no vibration, just a small blink. (If you like, you can enable sounds and vibration for notifications, for sure. You can set sounds and vibration patters per type of notification and per contact – but I don’t need all that, I simply love the red blink).

Being silent in meetings automatically

The Passport knows when I’m in a meeting and enables silent mode automatically during that time. I don’t need to think of “I have to disable my phone” before I go into a meeting, it just happens automatically. Since my clients have my undivided attention in meetings, it’s a perfect feature for me.

No need for rotating the device

Since the display is a square anyway, there is no need to rotate the device. Some may think of this as a disadvantage, I feel it’s more comfortable this way.


The keyboard is just great, great, great. It is worth the Passport alone. Really. I. love. it.

Beside that, there are a lot of small features that make the BlackBerry Passport a really productive machine. So far, I like it.


Oct 27

My BlackBerry Passport arrived – first impressions

Last week Amazon was able to deliver the BlackBerry Passport, so I ordered again and got it on Wednesday.

Since my iPhone 4S uses a micro SIM, I needed to order a nano SIM for the Passport, which I did on Thursday. But that also meant that I didn’t had a SIM for the Passport when I did it’s setup. That lead to one interesting problem, but more about that later.

Form factor

You know, the BlackBerry Passport ist very wide. I have to get used to this form factor, but on the other hand it has some big advantages:

  • No need to rotate the device since the display is a squarish.
  • Space for the keyboard with real keys.

Using the Passport as classic phone by holding it with one hand onto my ear feels weird, but I will do that very seldom anyway. I don’t make calls with a mobile phone frequently, and if so, I will use a headset or the car’s phone system.


Setting up my accounts was no problem. Some notes:

  • No need to look for an “Exchange” account in order to use with IBM Traveler. The BlackBerry Passport does support IBM Traveler as an account type of it’s own.
  • You can use iCloud contacts and calendar by setting up a CardDAV account using “contacts.icloud.com”. CalDAV should work similar.
  • Do not download the BlackBerry Desktop software. It’s for older BlackBerry only! Download BlackBerry Link instead. I tried BlackBerry Desktop first since I didn’t see any message that it does not support BB 10 devices, and then I didn’t understood why it was not able to work with my Passport…
  • Download BlackBerry Blend, too. See below.

Desktop Software

BlackBerry Link synchronizes music, photos, documents etc. to the device via wire (USB) or network (WLAN). It’s very simple to use and works without problems. If you want to synchronize playlists from iTunes, right click the playlist in BlackBerry Link and select “synchronize to device”. If you just drag and drop the playlist to the device only the songs will by copied to the device, not the playlist itself.

BlackBerry Blend is very innovative and impressive. It allows you to work with your BB 10 device from your desktop or tablet. That includes:

  • Read and write mail / using the BlackBerry Hub.
  • Read and write text messages (SMS).
  • Read and write BBM chat messages (if you have anyone who is using BBM 🙂 )
  • Working with the calendar and contacts.
  • Transferring files with drag & drop.

That’s cool from the desktop, but that’s even more useful from my iPad! For example, if I want to reply to a mail that I got via IBM Notes, but my Notes is busy or the virtual machine where Notes lives does not run I can write the mail from my desktop using the big screen and full size keyboard and send it via the BlackBerry.

Or if I want to copy some files to the BlackBerry, I can simply drag & drop them to the device using Blackberry Blend. No need for iTunes with it’s long synchronization process.

BlackBerry 10 software

I like the BlackBerry 10 software on the device, too. It looks good, if works fast and without problems. There are useful gestures (like for example one gesture to get to the BlackBerry Hub

BlackBerry Hub is the center for all mails and works great. It supports keyboard shortcuts and various very useful features in order to get your mail work done very fast.

The contacts app does synchronize my contacts from iCloud, but it does not show any contact. That bugged my a lot until I learned that the cause is that I did the setup without having a SIM installed. I doubt that this behaviour is intended. Most probably the problem will go away when I have my nano SIM.

Otherwise, the BlackBerry 10 system has a lot of apps and connectivity out of the box, for example to Evernote, Dropbox etc.


So far I found few useful native BlackBerry 10 apps. Most apps I installed are Android apps that I got from the build in Amazon Appstore. You can install an app via an Android APK file, too.

But why searching for Apps that replace the iOS apps I used I found one thing: very, very many Android apps are just trash.

For example I looked for a simple stock market App where I can watch some stocks. I tried five Android apps, and they were all just advertising platforms with limited functionality, force me to register somewhere in order to monitor my stock market behaviour, or both.

I guess the problem is that I want to pay for an app. The average Android user seems to expect that an app is free, and therefore developers are forced to use bugging ads in order to make some money.

So I learned that when an app is free, I can skip it in the first place. Overall, I feel the general quality of iOS apps is much, much better. So far being forced to use Android apps feels like a huge step backward.

Android App Security makes me feel uncomfortable

One thing that concerns me very much is the Android security system (or the lack of) and how many rights apps are asking for. For example, while I tried stock marked apps, most apps asked me for rights like reading contacts, location, messages etc. For a stock marked app?!? Not very trustworthily, is it?

Furthermore, you cannot give or lock specific rights per app, you can only grant all the rights an app asks for or you cannot use the app at all.

I really wonder why Google thinks that this total lack of security is a good thing. I makes me feel very, very uncomfortable.

Working fast with the keyboard

The hardware keyboard is one very strong argument for the Passport. After one day I was faster writing mails or other texts that with the iPhone after years!

Three lines of hardware keyboard combined with one or more lines of soft keyboard on the display is a very, very good idea and works just perfect.

Furthermore the keyboard is touch enabled, too. So for example you can scroll through a website my swiping over the keyboard and without obscuring the display with your hand. Extremely useful!

Miscellaneous impressions

  • The BlackBerry Passport blinks when it got a new message. I like this subtile way of being notified very much.
  • The battery holds longer than on my iPhone 4S.
  • Streaming music via bluetooth produces more audibility than with the iPhone.
  • It’s a relief to have a bigger display. Reading stuff on the iPhone 4S is very hard compared to the Passport. Since iPhone 6 has a bigger display, too, that’s no general advantage – but to me coming from the 4S, it is.

That’s it so far. The BlackBerry Passport is an excellent communication machine with a lot of advantages and the disadvantage of being forced to use Android apps when there is no appropriate BB 10 app. I will report back after some time.


Oct 21

What happened to my BlackBerry Passport which I ordered instead of an iPhone 6?

Some days ago I wrote about ordering a BlackBerry Passport instead of an iPhone 6. But I never wrote anything about the device yet…

The reason is simple: I didn’t got it. The store where I ordered was not able to deliver, and neither is Amazon or various local stores.

So I canceled my order and I’m waiting until Amazon is able to deliver the Passport again. I’m not in a hurry at all, I still have my iPhone 4S which works just fine.

Oct 21

First steps and issues with Titanium, DominoToGo and Blackberry 10

Today I started with Blackberry 10 development using Appcelerator Titanium and DominoToGo. Setup of the development environment was easy since there is a good guide in the Titanium documentation.

There are a few things to watch out for, though:

  • Make sure you follow the guide to create a debug token. That’s NOT the BlackBerry ID token created in the BlackBerry Deployment Setup Wizard in the Momentics IDE! See Momentics IDE – Properties – BlackBerry – Signing to create a debug token. It will create a *.bar file which you can use in Titanium’s Studio properties.
  • To access the file system of the BlackBerry simulator, use a ftp client and log into the IP that is displayed in the lower left corner of the simulator. Use “devuser” as user and passwort.
  • In BlackBerry’s file system the app data is stored in /accounts/1000/appdata/<app id>.
  • Do not switch off development mode in the simulator! If you ever switched that off, you need to enter a device password in order to enable development mode again. And if you did that, you cannot use the standard run command of Titanium Studio, since it doesn’t use the password you may have set in the run configuration.
    There is a workaround for that, too, using CLI in terminal. But it’s annoying, so better don’t touch the development mode switch in the first place.

The most recent version of DominoToGo has issues on BlackBerry 10 because Appcelerator simply didn’t implemented some features of the Titanium SDK for BlackBerry yet. One missing functionality is a file stream, which DominoToGo uses when data downloaded from Domino is huge (multiple megabytes). So far I’m using in-memory processing instead of file streams as a workaround.

The SQLite database implementation is missing the ‘rowsAffected’ property which I’m using in some database operations. I have to find a workaround for that, too.

I’m sure there will be more issues I will come across in the next weeks. But the good news is that a lot of important functionality is working just fine on BlackBerry 10, such as HTTP connectivity, reading and writing files and most database operations.