02-28-2013 09:26 AM
I am a BlackBerry development newbie, but have some HTML5/CSS/Javascript experience.
I am in the process of designing and building a "virtual tabletop" PlayBook app. One major feature I plan to incorporate into my application is the ability to create locally-stored, editable Character Records. It's pretty obvious that I'll need to store the data locally somehow, but I can't work out the best method to use.
I am aware that there are a number of different data storage / retrieval methods - I just can't work out the advantages of any one over another. Can anyone point me in the right direction, please?
As an aside, I currently have NO access to a Windows PC (or a Mac, for that matter!). I'm hard-coding the pages in a Text Editor on my BlackBerry Curve, uploading the pages to the Web and viewing the results on my PlayBook's Browser - things like plugins for Eclipse or WebWorks are a no-go, I'm afraid...
Thanks in advance for your help,
Blackbow
03-01-2013 12:37 PM
Localstorage is easiest to use, you would have your characters in JSON objects and just stringify them before storing in the variables. However, I'm guessing that with the type of application you are doing, it would lend itself very well to tabular data - all the characters have the same attributes and you may want to run SQL operations on multiple characters at a time. You will likely find limitations of the localstorage approach fairly soon as you progress in your development.
Since you don't have a PC, you might actually benefit from this odd bit of trivia. You can actually use WebInspector in the PlayBook Browser to debug your webpage in the same Browser. Just turn on WebInspector, open a new tab and go the the Wifi IP of your PlayBook, with the port 1337. It's small, but it may help to be able to run the odd console command or look at your SQL tables.
03-01-2013 01:02 PM
03-01-2013 06:52 PM
I would go with SQLite for persistent storage for a long term solution. Local storage is definitely easier to use, as it sticks to the key/value pair.
03-01-2013 07:27 PM - edited 03-01-2013 07:29 PM
@twindsor: Thanks for your help ![]()
I agree with you, the tabular option seems to be the best to go for...
Am I right in assuming that each character is represented by a row, and that each column in a table represents an attribute? And that I can have more than one table (characters, monsters, items, etc.)?
Thanks also for the tip about the WebInspector - I've added it to my bookmarks!!
Blackbow : )
03-01-2013 07:37 PM
Yes, you can have multiple tables. The row is the data that you put in.
ex:
I have a table for members. The columns would be something like first_name, last_name, address, etc...
I insert a record into the members table, John Smith where i'm putting John as first_name and Smith as last_name.
When i do a query on the table, it would look something like this
db.transaction(function(tx){
tx.executeSql('SELECT * FROM MEMBERS', [ ], function(tx,results){
for (var i=0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var firstName = row.first_name;
var lastName = row.last_name;
}
});
});
03-02-2013 03:17 AM
Thanks for the help....
Am I right in thinking that in your code example, the query would return a list of first and last names for ALL entries in the database?
If so, how would I query ONE result (column) from ONE line? For example, how could I find the Email_Address in the Row representing John Doe?
Thanks for your patience - it's a lot to get my head around!! ![]()
03-04-2013 06:06 AM
"One issue you may run into with a DB is the lag time involved in DB operations"
@mikefromcanada - Is this the case on BB10 or did you experience this lag on BBOS (Java) ?