DbHelper.java :  » UnTagged » myway-tracker » cz » byteworks » android » myway » db » Android Open Source

Android Open Source » UnTagged » myway tracker 
myway tracker » cz » byteworks » android » myway » db » DbHelper.java
package cz.byteworks.android.myway.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class DbHelper extends SQLiteOpenHelper {

  private static final int DATABASE_VERSION = 2;

  private static final String DATABASE_CREATE1 = "create table MYWAY_POSITIONS ( PID" + " integer primary key autoincrement, " + "locate_time integer not null, latitude real not null, longitude real not null, altitude real, note text, mark integer, fk_way_id integer, locality text);";
  private static final String DATABASE_CREATE2 = "create table MYWAY_WAYS (WID integer primary key autoincrement, create_time integer not null, name text not null);";

  public DbHelper(Context context, String name, CursorFactory factory, int version) {
    super(context, name, factory, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    db.execSQL(DATABASE_CREATE1);
    db.execSQL(DATABASE_CREATE2);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    if (oldVersion == 1 && newVersion > 1) {
      db.execSQL("ALTER TABLE MYWAY_POSITIONS ADD locality text");
    }
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.