Back to project page commit-android.
The source code is released under:
GNU General Public License
If you think the Android project commit-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.mauriciogiordano.commit.database; /* w w w . j a v a 2s .com*/ 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; import com.j256.ormlite.table.TableUtils; import com.mauriciogiordano.commit.R; import java.sql.SQLException; public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public static final int DATABASE_VERSION = 7; private Dao<Commitment, Integer> commitmentDao = null; private Dao<Commit, Integer> commitDao = null; public static ConnectionSource cs; public DatabaseHelper(Context context) { super(context, "commit.db", null, DATABASE_VERSION, R.raw.orm_config); } @Override public void onCreate(SQLiteDatabase database, ConnectionSource cs) { try { TableUtils.createTable(cs, Commitment.class); TableUtils.createTable(cs, Commit.class); DatabaseHelper.cs = cs; } catch (SQLException e) { e.printStackTrace(); } } @Override public void onUpgrade(SQLiteDatabase database, ConnectionSource cs, int oldVersion, int newVersion) { try { TableUtils.dropTable(cs, Commitment.class, true); TableUtils.dropTable(cs, Commit.class, true); onCreate(database, cs); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public Dao<Commitment, Integer> getCommitmentDao() throws SQLException { if(commitmentDao == null) { commitmentDao = getDao(Commitment.class); } return commitmentDao; } public Dao<Commit, Integer> getCommitDao() throws SQLException { if(commitDao == null) { commitDao = getDao(Commit.class); } return commitDao; } }