Android Open Source - dNote D M Database Helper






From Project

Back to project page dNote.

License

The source code is released under:

GNU General Public License

If you think the Android project dNote 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.digutsoft.note.classes;
// ww  w .j ava  2  s  .c om
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.digutsoft.note.R;
import com.digutsoft.note.classes.DMMemoTools;

import java.util.ArrayList;

public class DMDatabaseHelper extends SQLiteOpenHelper {
    Context mContext;

    public DMDatabaseHelper(Context context) {
        super(context, "dNoteDatabase.db", null, 2);
        mContext = context;
    }

    public void onCreate(SQLiteDatabase database) {
        String mCategoryName = mContext.getResources().getString(R.string.default_category_name);
        database.execSQL("CREATE TABLE __CategoryList (cateIndex INTEGER PRIMARY KEY NOT NULL, cateName TEXT);");//, catePass TEXT);");
        database.execSQL("CREATE TABLE \"" + mCategoryName + "\" (memoId INTEGER PRIMARY KEY, memoTitle TEXT, memoContent TEXT, checkStatus INTEGER);");
        database.execSQL("INSERT INTO __CategoryList (cateName) VALUES (\"" + mCategoryName + "\");");

    }

    public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        ArrayList<String> categoryList = new ArrayList<>();

        Cursor cursor = database.rawQuery("SELECT * FROM __CategoryList ORDER BY cateIndex ASC", null);
        while (cursor.moveToNext()) {
            categoryList.add(cursor.getString(1));
        }

        for (int i = 0; i < categoryList.size(); i++) {
            database.execSQL(String.format("ALTER TABLE \"%s\" ADD checkStatus INTEGER;", DMMemoTools.addSlashes(categoryList.get(i))));
        }
    }
}




Java Source Code List

android.support.v4.preference.PreferenceFragment.java
android.support.v4.preference.PreferenceManagerCompat.java
android.support.v4.preferencefragment.BuildConfig.java
android.support.v4.preferencefragment.BuildConfig.java
com.digutsoft.note.DMCategoryManager.java
com.digutsoft.note.DMMain.java
com.digutsoft.note.DMMemoView.java
com.digutsoft.note.DMNewNote.java
com.digutsoft.note.DMSaveFromWear.java
com.digutsoft.note.DMSaveFrom.java
com.digutsoft.note.DMSettingsFragment.java
com.digutsoft.note.DMSettings.java
com.digutsoft.note.DMSplash.java
com.digutsoft.note.DMWearVoiceAction.java
com.digutsoft.note.DrawerMenuList.java
com.digutsoft.note.NavigationDrawerFragment.java
com.digutsoft.note.classes.DMDatabaseHelper.java
com.digutsoft.note.classes.DMMemoList.java
com.digutsoft.note.classes.DMMemoTools.java