Android Open Source - UniApp Database Helper






From Project

Back to project page UniApp.

License

The source code is released under:

MIT License

If you think the Android project UniApp 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 it.nic.uniapp.db;
/*from   w  w w  .  jav a  2s.  co  m*/
import it.nic.uniapp.core.Constants;

import java.sql.SQLException;


import it.nic.uniapp.R;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;

public class DatabaseHelper extends OrmLiteSqliteOpenHelper{

  private static final int DB_VERSION = 1;
  private Dao<EsameEntity, Integer> esameEntityRuntimeDao = null;
  
  public DatabaseHelper(Context context)
  {
    super(context, Constants.DB_NAME, null, DB_VERSION,R.raw.esami_config );
  }
  
  /**
   * This is called when the database is first created. Usually you should
   * call createTable statements here to create the tables that will store
   * your data.
   */
  @Override
  public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource)
  {}

  /**
   * This is called when your application is upgraded and it has a higher
   * version number. This allows you to adjust the various data to match the
   * new version number.
   */
  @Override
  public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion)
  {}
  
  public Dao<EsameEntity, Integer> getEsameEntityDao() throws SQLException
  {
    if (this.esameEntityRuntimeDao == null)
    {
      this.esameEntityRuntimeDao = getDao(EsameEntity.class);
    }

    return this.esameEntityRuntimeDao;
  }
  
  @Override
  public void close()
  {
    if (this.isOpen())
    {
      super.close();

      try
      {
        if (esameEntityRuntimeDao != null)
        {
          esameEntityRuntimeDao.closeLastIterator();
        }
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }

      esameEntityRuntimeDao = null;
    }
  }
}




Java Source Code List

it.nic.uniapp.AddEsame.java
it.nic.uniapp.CalendarioEsami.java
it.nic.uniapp.FunzioniEsami.java
it.nic.uniapp.ListaEsami.java
it.nic.uniapp.MainActivity.java
it.nic.uniapp.PopUpWindow.java
it.nic.uniapp.UpdateEsame.java
it.nic.uniapp.adapters.EsameAdapter.java
it.nic.uniapp.adapters.GridCellAdapter.java
it.nic.uniapp.cmp.EsameRowControl.java
it.nic.uniapp.core.Constants.java
it.nic.uniapp.core.PageLoader.java
it.nic.uniapp.db.DBHandler.java
it.nic.uniapp.db.DatabaseConfigUtil.java
it.nic.uniapp.db.DatabaseHelper.java
it.nic.uniapp.db.EsameEntity.java
it.nic.uniapp.db.IDBHandler.java
it.nic.uniapp.util.Util.java