By Nic Raboy
When developing an Ionic 2 application there are often scenarios where it probably isn’t a good idea to include repetitive source code in multiple application pages. A common example of this would be when it comes to database interaction in an Ionic 2 application. Sure you could establish a connection to the database on every page and query it, but it would probably make more sense to use it like a shared provider.
We’re going to see how to create a SQLite shared provider, often referred to as a shared service or sometimes a singleton class, in an Ionic 2 Android and iOS application using Angular 2.
To make what we’re about to cover as easy to understand as possible, we’re going to start with a fresh Ionic 2 project. From your Terminal (Mac and Linux) or Command Prompt (Windows), execute the following: