Android Open Source - text-snippets My S Q Lite Helper






From Project

Back to project page text-snippets.

License

The source code is released under:

GNU General Public License

If you think the Android project text-snippets 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.sirimangalo.textsnippets;
/*  ww  w .  ja va  2  s  . c  o  m*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;

public class MySQLiteHelper extends SQLiteOpenHelper {
  public static final Uri URI_TABLE = 
        Uri.parse("sqlite://org.sirimangalo.textsnippets/snippets");
  public static final String TABLE_SNIPPETS = "snippets";
  public static final String COLUMN_ID = "_id";
  public static final String COLUMN_SNIPPET = "snippet";
  public static final String COLUMN_COMMENT = "comment";
    public static final Object[] dbLock = new Object[0];

    private static final String DATABASE_NAME = "snippets.db";
  private static final int DATABASE_VERSION = 2;

  // Database creation sql statement
  private static final String DATABASE_CREATE = "create table "
      + TABLE_SNIPPETS + "(" 
      + COLUMN_ID + " integer primary key autoincrement, " 
      + COLUMN_SNIPPET + " text,"
      + COLUMN_COMMENT + " text"
      +");";

  public MySQLiteHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase database) {
    database.execSQL(DATABASE_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    if (oldVersion < 2) {
        db.execSQL("ALTER TABLE " + TABLE_SNIPPETS + " ADD COLUMN " + COLUMN_COMMENT + " text");
    }
  }

}




Java Source Code List

org.sirimangalo.textsnippets.MySQLiteHelper.java
org.sirimangalo.textsnippets.SnippetAdapter.java
org.sirimangalo.textsnippets.SnippetWidgetProvider.java
org.sirimangalo.textsnippets.SnippetWidgetService.java
org.sirimangalo.textsnippets.Snippet.java
org.sirimangalo.textsnippets.SnippetsActivity.java
org.sirimangalo.textsnippets.SnippetsDataSource.java
org.sirimangalo.textsnippets.TextSnippetsBackupAgent.java