Android Open Source - GPSMover Database Open Helper






From Project

Back to project page GPSMover.

License

The source code is released under:

GNU General Public License

If you think the Android project GPSMover 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.unlucky.gpsmover.app.db;
/*from  ww w  . j  a  v a  2 s. com*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseOpenHelper extends SQLiteOpenHelper {
    private final static int DB_VERSION = 1;
    private final static String DB_NAME = "gpsmover.db";

    public DatabaseOpenHelper(Context context) {
        this(context, DB_NAME, null, DB_VERSION);
    }

    public DatabaseOpenHelper(Context context, String db_name, CursorFactory factory, int version) {
        super(context, db_name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // create tb_favorites
        String sql = "create table " + FavoritesHelper.TABLE_NAME + " (";
        for (int i=0; i<FavoritesHelper.FIELD_NAME.length; i++) {
            if (i > 0) sql += ",";
            sql += FavoritesHelper.FIELD_NAME[i] + " " + FavoritesHelper.FIELD_TYPE[i];
        }
        sql += ")";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql = "drop table if exists " + FavoritesHelper.FIELD_NAME;
        onCreate(db);
    }
}




Java Source Code List

org.unlucky.gpsmover.app.AddLocationDialogFragment.java
org.unlucky.gpsmover.app.FavLocationDialogFragment.java
org.unlucky.gpsmover.app.FavLocationListAdapter.java
org.unlucky.gpsmover.app.GPSMoverService.java
org.unlucky.gpsmover.app.GotoLocationDialogFragment.java
org.unlucky.gpsmover.app.MainActivity.java
org.unlucky.gpsmover.app.SettingsActivity.java
org.unlucky.gpsmover.app.db.DatabaseOpenHelper.java
org.unlucky.gpsmover.app.db.FavoriteLocation.java
org.unlucky.gpsmover.app.db.FavoritesHelper.java
org.unlucky.gpsmover.app.util.Common.java