Phonegap sqlite tutorial12/13/2023 There's a lot more logic around to handle my form editing and the like, but you can see that yourself in the attached zip. It looks like you can't do named parameters like you can in Adobe AIR, so make your get your positions right.Īnd that's pretty much it. Also note how i handle the bound parameters. Notice how I handle insert versus update logic. The cb argument is simply a call back to execute. It's got values for title, body, and possibly the ID. So before we start - I'll say that the note argument is a simple JavaScript object. I began by having it call a function named phoneReady:įunction phoneReady() This event is fired by PhoneGap when the hardware is ready for business time. So how does it work? I've got an event handler that listens in for the deviceready event. You can click a note to edit it, or simply click Add Note. The first is a list of your current notes. It's a very poor, very limited note taking application. My demo application is called SimpleNotes. Ok - so let's talk about the application. The application reported it as a database error because the transaction callback was executing. It tended to bite me in the rear because I made the mistake of running "executeSQL" on my transaction object instead of "executeSql". This adds a level of complexity to your code that may be a bit confusing at first, but once you've worked through a couple of examples it really isn't that big of a deal. Second - while both AIR and PhoneGap support transactions through SQLite, PhoneGap requires all SQL transactions to go through a transaction. Again - with PhoneGap you only have the asynchronous option. I'll have a synchronous one for setup and then an asynchronous one to handle post-launch operations. I'll typically use two connections in an AIR app. They can lock your application up if you need to perform a particularly long operation, but I like having the option at least. That's not a bad thing typically, but I tend to prefer synchronous connections since they are a lot simpler to work with. The W3C docs for SQLError though have both the labels and the codes.įor folks who are familiar with SQLite in AIR, there are two main differences I've found between the AIR and PhoneGap platforms.įirst - it seems (although I've not confirmed this) that PhoneGap only supports asynchronous connections. As an example, the PhoneGap docs enumerate the error codes for the SQLError object, but don't tell you the actual values that go with them. It definitely helped fill in some things that the PhoneGap docs didn't cover. Consider yourself warned.Īlong with PhoneGap's docs, you want to read the W3C spec for Web SQL Database support. It isn't that PhoneGap is brittle per se, but you really need to ensure you know what you're doing. I guess I shouldn't be surprised there, but with PhoneGap I've found it really critical to carefully read the docs. I don't know why - but the biggest issue I've had with PhoneGap so far has been around my incorrect assumptions not matching up with reality. I'll also point out some of the mistakes I made while writing so that hopefully you can avoid the issues I ran into.įirst - it is important to carefully read PhoneGap's storage documentation. In this blog entry I'll walk you through a sample application I've created that makes use of the feature. PhoneGap also has built in support for SQLite via their storage support. This is incredibly useful for applications and pretty darn easy to use as well. Any AIR application (whether written in Flex or HTML - you do remember you can do AIR with HTML, right?) can make use of an embedded SQLite database. Folks who have used Adobe AIR before already know (or hopefully know) about it's cool, built-in database support.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |