Android Open Source - passby Database Helper






From Project

Back to project page passby.

License

The source code is released under:

Copyright 2014 Firebase, https://www.firebase.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ?Software??...

If you think the Android project passby listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//#CSIT6000B#  Rio He       20227977 yheas@connect.ust.hk
//#CSIT6000B#  Cedric Liang 20220395 zliangag@connect.ust.hk
//#CSIT6000B#  Kevin Wang   20225577 zwangbo@connect.ust.hk  
package com.firebase.database;
/*from  w  ww. ja v a 2s  . c  o  m*/
import android.annotation.SuppressLint;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
  private static final int DATABASE_VERSION = 1;
  private static final String DATABASE_NAME = "PASSERBY.db";
  public static final String TABLE_NAME = "UserTable";
  
  public DatabaseHelper(Context context, String name, CursorFactory factory, int version) {
    super(context, name, factory, version);
    // TODO Auto-generated constructor stub
  }

  @SuppressLint("NewApi") 
  public DatabaseHelper(Context context, String name, CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
    super(context, name, factory, version, errorHandler);
    // TODO Auto-generated constructor stub
  }
  
  public DatabaseHelper(Context context){
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  // when creating database, onCreate will be called
  @Override
  public void onCreate(SQLiteDatabase db) {
    
    // create SQL statement
    StringBuffer sBuffer = new StringBuffer();
    sBuffer.append("CREATE TABLE " + TABLE_NAME + " (");
    sBuffer.append("uid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, ");
    sBuffer.append("nickname VARCHAR,");
    sBuffer.append("gender INTEGER)");
    
    // execute creation
    db.execSQL(sBuffer.toString());
  }

  // when version is changed, onUpgrade will be called
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
     db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
     onCreate(db);
  }

  // everytime db is openned, onOpen will be executed
  @Override
  public void onOpen(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    super.onOpen(db);
  }

  
}




Java Source Code List

com.firebase.androidchat.ChatListAdapter.java
com.firebase.androidchat.Chat.java
com.firebase.androidchat.FirebaseListAdapter.java
com.firebase.androidchat.MainActivity.java
com.firebase.client.LaunchActivity.java
com.firebase.client.LocateActivity.java
com.firebase.client.SearchResultActivity.java
com.firebase.client.SettingActivity.java
com.firebase.database.DatabaseHelper.java
com.firebase.database.DatabaseManager.java
com.firebase.database.DatabaseTask.java
com.firebase.database.User.java