Update the application database

Asked

Viewed 29 times

0

I’m a beginner in app programming. I’m developing an ionic 2 with the angular 2. A doubt has arisen, I have a provider and in it I do all part of the database using the SQLite, just that there was a need to add a field to the table , up to there everything , I added the field, but there was a problem I had to uninstall the application to make the update work, then in this respect I lost all the data , I practically reset the bank to have the update installed.

There would be some way to do this update without having to reset the database by uninstalling the application ?

Follows my provider.

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';

@Injectable()
 export class RomaneioBdSql {
 storage: any;
 public romaneios: Array<Object>;

 constructor(public http: Http, public sqlite: SQLite) {
   this.sqlite.create({
    name: 'infoged.db',
    location: 'default'
  }).then((db: SQLiteObject) => {
    db.executeSql('create table IF NOT EXISTS tb_romaneio(id_romaneio INTEGER PRIMARY KEY AUTOINCREMENT,' +
    'romaneio_name VARCHAR(32),' +
    'romaneio_motorista VARCHAR(52) default NULL, ' +
    'romaneio_nota VARCHAR(19),' +
    'romaneio_serie VARCHAR(9),' +
    'romaneio_sincronizada integer(1) default 0' +
    ')', {})
    .then(ed => /*alert(JSON.stringify(ed))*/ed)
    .catch(e => alert(JSON.stringify(e)));
}).catch(e => alert(JSON.stringify(e)));

}

  • 1

    This post should help you: https://answall.com/questions/152297/comoractualizr-meu-aplicativo-pelo-apk-sem-perder-meu-banco-data

  • Thank you Nilson , began to give a clear!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.