Android Open Source - Abidan D B Helper






From Project

Back to project page Abidan.

License

The source code is released under:

Apache License

If you think the Android project Abidan 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.poepoemyintswe.abidan.db;
//w ww.j av a2s . c om
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.poepoemyintswe.abidan.utils.SharePref;
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;

/**
 * Created by poepoe on 12/8/14.
 */
public class DBHelper extends SQLiteAssetHelper {
  private static final String DATABASE_NAME = "ornagai.sql";
  private static final int DATABASE_VERSION = 1;

  private static DBHelper dbHelper;
  private SQLiteDatabase db;

  private Context mContext;

  public DBHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    this.mContext = context;
  }

  public static synchronized DBHelper getInstance(Context mContext) {
    if (dbHelper == null) {
      dbHelper = new DBHelper(mContext);
    }
    return dbHelper;
  }

  public void open() throws SQLException {
    this.db = getWritableDatabase();
  }

  public void close() {
    this.db.close();
  }

  public Cursor searchWord(String word) throws SQLException {
    open();
    String query = "SELECT * FROM " + SharePref.getInstance(mContext).geDB() + " WHERE word LIKE ?";
    Cursor c = this.db.rawQuery(query, new String[] { word + "%" });
    return c;
  }

  public Cursor searchWord() throws SQLException {
    open();
    String query = "SELECT * FROM " + SharePref.getInstance(mContext).geDB();
    Cursor c = this.db.rawQuery(query, null);
    return c;
  }
}




Java Source Code List

com.poepoemyintswe.abidan.ApplicationTest.java
com.poepoemyintswe.abidan.Config.java
com.poepoemyintswe.abidan.SearchActivity.java
com.poepoemyintswe.abidan.adapter.WordAdapter.java
com.poepoemyintswe.abidan.async.WordAsync.java
com.poepoemyintswe.abidan.db.DBHelper.java
com.poepoemyintswe.abidan.models.Word.java
com.poepoemyintswe.abidan.utils.SharePref.java