Android Open Source - easydb S Q L Helper






From Project

Back to project page easydb.

License

The source code is released under:

Apache License

If you think the Android project easydb 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

package com.san.api.easydb;
//w  ww  .  j  a v a2s .com
import java.util.ArrayList;

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

public class SQLHelper extends SQLiteOpenHelper {

  private ArrayList<Class>      entityList;
  private EntityProcessor  mEntityProcessor;

  public SQLHelper(Context context,String dataBaseName, ArrayList<Class> entityList) {
    super(context, dataBaseName, null, 1);
    
    this.entityList=entityList;
    this.mEntityProcessor = new EntityProcessor();

  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    try {
      for (Class c : entityList) {
        db.execSQL(mEntityProcessor.getCreateSQL(c));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    try {
      for (Class c : entityList) {
        db.execSQL(mEntityProcessor.getDropSQL(c));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    onCreate(db);
  }

}




Java Source Code List

com.san.api.easydb.ConnectionManager.java
com.san.api.easydb.EntityProcessor.java
com.san.api.easydb.Entity.java
com.san.api.easydb.SQLHelper.java
com.san.api.easydb.Session.java
com.san.api.easydb.example.MyEntityClass.java
com.san.api.easydb.example.MyListAdapter.java
com.san.api.easydb.example.TestActivity.java