Android Open Source - easydb Connection Manager






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;
//from   w  w  w .  jav a 2  s  . c o m
import java.util.ArrayList;

import android.content.Context;

/**
 * 
 * @author Santanu Kumar
 */
final public class ConnectionManager {
  protected static ArrayList<Class> ENTITY_LIST=new ArrayList<Class>();
  private SQLHelper    mDBHelper;
  private Session      session;
  private static ConnectionManager CONNECTION_MANAGER;
  
  private ConnectionManager(Context context,String database) {
    this.mDBHelper = new SQLHelper(context,database,ENTITY_LIST);
  }

  public static ConnectionManager createConnectionManager(Context context,String database) {
    if(CONNECTION_MANAGER==null)
      CONNECTION_MANAGER=new ConnectionManager(context,database);
    
    return CONNECTION_MANAGER;
  }
  
  /**
   * 
   * @param className
   */
  public static void registerEntity(Class className) {
    ENTITY_LIST.add(className);
  }
  
  /**
   * 
   * @return
   */
  public Session openSession(){
    session = new Session(mDBHelper.getWritableDatabase());
    return session;
  }

  /**
   * 
   */
  public void dispose() {
    if (mDBHelper != null) {
      mDBHelper.close();
    }
    CONNECTION_MANAGER=null;
  }
}




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