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

Adobe AIR Development

Reply
Developer
eugenevk
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
Accepted Solution

Testing a SQLite database conversion: please advise

Hi,

 

In my app I use a SQLite database for storing the data. I am about to release a new version that contains multiple additions and changes to the database. I obviously need to test the conversion, but have no idea how to simulate that. I have two projects in FlashBuilder, one contains the old version, the other the new release. The name of the projects need to be different and so the name of the <app name>-app.xml, but the content is the same, except for the version number. So the <id> is also the same. I expected that that would do the trick to access the old database from the old project by the new project, but it doesn't seem to happen.

Any ideas or suggestions are highly appreciated.

Eugene

My PlayBook App: Checklists
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Testing a SQLite database conversion: please advise

Is the DB file in the app-storage directory? The app path is based on the app id (+ if in debug mode). If you are running under windows, you can run it there and see the app-storage directories. Are you running the old app, and then installing the new app to access the old DB file?
Developer
eugenevk
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000

Re: Testing a SQLite database conversion: please advise

Hi John,

 

I am testing the app on the PB simulator on a Mac. I use the following statement (in the old as well as in the new app) to open the database:

File.applicationStorageDirectory.resolvePath("Checklists.db");

I have no clue where to find the database of the old version (that I run in debug mode in the simulator as well obviously) and then test the upgrade.

 

Eugene

My PlayBook App: Checklists
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Testing a SQLite database conversion: please advise

I assume that statement is being set to a File object.
When in debug, the app storage area is different then a released (non-debug) version, so if you are trying to obtain the DB file for an earlier release, it wont be there.

The same file command should be able to obtain the DB file. Are you trying to do something like this (pseudo code):

IF "Checklists2.db" NOT EXIST
IF "Checklists.db" DOES EXIST
CONVERT DB to Checklists2.db
ENDIF
ENDIF
OPEN "Checlists2.db" file
Developer
eugenevk
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000

Re: Testing a SQLite database conversion: please advise

No, I just try to open the database with the same name:

...
private var _checklistsDB:File;
...

private function openDb () : void { ... // open database _checklistsDB = File.applicationStorageDirectory.resolvePath("Checklists.db");
_sqlQuery.sqlConnection = _sqlCon; with (_sqlCon) { addEventListener(SQLEvent.OPEN, onOpenDB);
addEventListener(SQLErrorEvent.ERROR, onDbError);
open(_checklistsDB);
}
}
...

 In function onOpenDB is do the conversion.

Eugene

My PlayBook App: Checklists
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Testing a SQLite database conversion: please advise

If you are opening the same file, how do you know that it might need to be converted?
If this helps, in my DB files, I always have an "info" table that has at least one field that maintains the "revision" of the DB. From that value, I can determine if it needs to be updated in someway and then update the revision field in that table.
Developer
eugenevk
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000

Re: Testing a SQLite database conversion: please advise

Oh I use a SharedObject to determine that. I also have an "Info" table, but combine it with the SharedObject.

Eugene

My PlayBook App: Checklists
Developer
eugenevk
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000

Re: Testing a SQLite database conversion: please advise

I found the following way to test my upgrade: first copy and paste the code of the previous app version in the current .AS file and run it. Then add some data (e.g. via the simulator), then copy and paste the code of the new app version in the current .AS file and run it. Little bit cumbersome, but it works.
Eugene

My PlayBook App: Checklists