Fetch particular data from Native Storage Ionic

I am making a project in Ionic 2/3 in which i have to store data from URL(JSON) into Native Storage(Mobile) and then to fetch only particular data from Native Storage like I have stored Roll numbers and names of 10 students in local DB and i only want to fetch “Roll # 09.” So how should i do it ?

For native devices go with the SQLite plugin: https://ionicframework.com/docs/native/sqlite/

For browsers, I would use localStorage.

You can use localStorage for all platforms but beware that private browsing mode preferences carry over to web views, and thus localStorage is unreliable for hybrid apps.

I am looking for a Example :slight_smile:

localStorage is well documented on MDN and W3Schools. I would start there for examples.

The SQLite plugin docs provide examples on the plugin, and further documentation is on its GitHub page. How its used is usually determined by the app.

Most apps I write have a skeleton for interfacing with the SQLite plugin similar to the following:

export class SQLiteService {

  constructor(private sqlite: SQLite) {


  private mydb;

  public config(): Observable<any> {
    // create SQL DB

  public delValue(name: string) {
    // delete value from SQLite

  public putValue(name: string) {
    // delete value from SQLite

  public getValue(name: string) {
    // get a value from SQLite

There is actually an easier option: Use Ionic Storage: https://ionicframework.com/docs/storage/

On native devices (and if installed) it is backed by SQLite, but the API is very simple to use.

1 Like