Android Open Source - OOOSMS O O O S M S Db Helper






From Project

Back to project page OOOSMS.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project OOOSMS 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 org.blanco.android.ooosms.db;
/*from  w  w w .jav a2s . c  om*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.support.DatabaseConnection;

import java.sql.SQLException;

/**
 * Created by Alexandro Blanco <ti3r.bubblenet@gmail.com> on 11/29/13.
 */
public class OOOSMSDbHelper extends OrmLiteSqliteOpenHelper {

    public static final int OOSMSDB_HEAD_VERSION = 1;

    public OOOSMSDbHelper(Context context, int databaseVersion) {
        super(context, "OOSMSDB", null, databaseVersion);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {
        try {
            DatabaseConnection connection = connectionSource.getReadWriteConnection();
            connection.setAutoCommit(true);
            connection.executeStatement("Create Table ListEntries(_id numeric, phone text, message text, rowOrder numeric)",0);

        } catch (SQLException e) {
            throw new IllegalStateException("Unable to create tables for OOSMSDbHelper");
        }
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int i, int i2) {
        sqLiteDatabase.beginTransaction();
        sqLiteDatabase.execSQL("Create Table ListEntries(_id numeric, phone text, message text, rowOrder numeric)");
        sqLiteDatabase.endTransaction();
    }
}




Java Source Code List

org.blanco.android.ooosms.ListEntryFormFragment.java
org.blanco.android.ooosms.MainActivity.java
org.blanco.android.ooosms.db.Entry.java
org.blanco.android.ooosms.db.OOOSMSDbHelper.java