Cordova Sqlite plugin problems

I’m at a loss and hoping someone can give me some steer on where to go next…

I’ve followed this guide for using cordova sqlite in Ionic 2:

All seems to work when testing in Chrome using Ionic serve but when running my app in the iOS simulator or running the .ipa file on my phone it doesn’t seem to work. I’ve tried opening the project in xcode and debugging the simulator with Safari but I cannot see any errors in the xcode log but there doesn’t seem to be a storage db in Safari listed or a db anywhere on my file system.

I’m at a loss of where to go next. I’ve tried looking for examples online but there doesn’t seem to be an example app using the cordova sqlite and Ionic 2… the ones that do seem to use the Ionic 2 sqlstorage instead.

I guess my question is, firstly, should I switch to using sqlstorage in Ionic 2, would this be better in the long run? Or should I persist with the cordova sqlite plugin and if so how should I attempt to debug the simulator/running app?

Any tips would be greatly appreciated!

The answer is that in order to use the Ionic 2 SqlStorage you also have to have the Cordova plug n installed. In fact if you look at that tutorial again you’ll notice one of the first things he has you do after ionic start is install the Cordova plugin.

It works fine in the browser because ionic uses WebSQL there.

If you still have trouble with this, I would post your question on that blog and not this forum. Good luck.

Why? This is THE Ionic forum, no reason not to ask the question here… and there if need be.

The problem is you have the question and answers (or partial answers) scattered across multiple forums. I face this problem all the time with the PhoneGap forums.

As you answered, the issue really wasn’t with Ionic, but probably a missing plugin, which points to the Cordova layer and not the Ionic directly. Hence why I think it should be redirected.

Also I think if you have trouble with a tutorial, that is where you should begin your questioning. Talk to the author of the post, they should know the material best and hopefully be able to answer the issue (or refine the tutorial). Plus, Nic usually does a really nice job with his tutorials.

Understood. On the other hand the more questions, even ones like this where he simply didn’t follow the instructions/tutorial will build up a large knowledge base that future users can search when they make the same mistake.

Just my $0.02!

Thanks both for your thoughts. I posted here because I was hoping for general thoughts from other Ionic developers about how to approach sqlstorage and how to debug it. If anyone has any articles or example projects I would love to know.

The article I followed is great but as Ionic 2 is moving quite fast I’m not sure if the approach is still considered the correct way. Snippets of others using Ionic 2 sqlstorage seem quite different (in provider files with quite different syntax) to the article.

Either way I guess my problem is around debugging sqlstorage of which there’s not much documentation or examples that I can find. Maybe it’s more of a question for an Xcode forum :wink:

When debugging sqlStorage in safari you have to hit the refresh button in the inspect window (It’s really anoying to have to reload each time i want to see the inserted value in db).

Turns out I think the article was a little out of date with Ionic 2 beta. When I use the newer approach it seems to work fine. On a side note, I still have no idea how to debug sqlStorage in the Simulator. I cannot find the sql db anywhere on my file system and using Safari to inspect the Simulator doesn’t show any kind of sql storage db. But it works :slight_smile:

In emulator should be the same deal as device, inspecting with safari and tapping the refresh button inside the safari browser used to inspect should show the database in resources.

hi, what newer approach are you referring to? Got a link?

In chrome, you can see the sql.