Welcome!

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

Native Development

Reply
New Developer
DementedDevil
Posts: 7
Registered: ‎04-06-2012
My Device: Bold 9900

Headless Service reading from shared SQLite database problem

Hi All,

 

I have found a problem with headless services and was wondering if anyone had any ideas...

 

Okay I have a headless application written in two parts (a UI app and a service app) both of these apps link to a shared library that implements my data-access layer (using SQLite)

 

My UI app writes a new record to a table and then notifies my service app via invoke manager to reload it's configuration.

 

When my service reads it's configuration it fails to find the records that the UI app added.

 

First of all I thought it was a problem with file access (as the database was stored at ./data/mydatabase.db) but I have since moved it to (./shared/misc/mydatabase.db) to no avail (the UI app has no problem accessing the database whereever it is)

 

What I am wondering is whether there are limitations on what the headless portion of my application can see? Since it does not have a bar-descriptor of it's own I would have assumed it would inherit the permissions of the main UI app.

 

Secondly do I need to close the SQLite connection after each CRUD operation to ensure the other app will be able to read? Actually I will give that a go in a moment...

 

Anyway, any thoughts greatly appreciated.

If it ain't broke try harder...

My stuff: Bold 9900/PlayBook 64Gb/BB10 Dev Alpha B DTAC/Thailand

BESAdmin
WinServer 2008R2 / Exchange 2010
24Gb RAM, > 2TB HARDDISK

Developing for BB10 with Cascades, QML and C++
New Developer
DementedDevil
Posts: 7
Registered: ‎04-06-2012
My Device: Bold 9900

Re: Headless Service reading from shared SQLite database problem

Turns out that it was a problem with SQLite and how it handles BOOLEAN columns.

I have a table that has the following schema (there are more columns but I left those out for brevity)

 

CREATE TABLE IF NOT EXISTS MyTable (

  MyID INTEGER PRIMARY KEY AUTOINCREMENT,

  Enabled BOOLEAN,

  Name NVARCHAR(50)

  );

 

With this table if I issue the following SELECT statement it returns no rows even when I explicitly add rows that would match the query...

 

SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled=1;

 

I have also tried

 

SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled;

 

and

 

SELECT MyId, Enabled, Name FROM MyTable WHERE Enabled=True;

 

All return zero rows.

 

Since SQLite does not natively support boolean columns (it does a conversion - apparently to integer) then comparisons to 0 or 1 should work but don't appear to.

 

Since I use parameter binding during the insert I might try doing parameter binding for the select and see if that works when I get a moment. For now though I just get all the rows and filter manually when I read each row - PITA but it works well enough for me to move onto other parts of this app...

If it ain't broke try harder...

My stuff: Bold 9900/PlayBook 64Gb/BB10 Dev Alpha B DTAC/Thailand

BESAdmin
WinServer 2008R2 / Exchange 2010
24Gb RAM, > 2TB HARDDISK

Developing for BB10 with Cascades, QML and C++