Android Open Source - notes Notes Database Open Helper






From Project

Back to project page notes.

License

The source code is released under:

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute verbatim or...

If you think the Android project notes 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.iliakplv.notes.notes.db;
/*from   www . jav  a2s .  c  o  m*/
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.iliakplv.notes.NotesApplication;
import com.iliakplv.notes.utils.AppLog;

/* package */ class NotesDatabaseOpenHelper extends SQLiteOpenHelper {

  private static final String LOG_TAG = NotesDatabaseOpenHelper.class.getSimpleName();

  static final int DATABASE_VERSION_FIRST = 1;     // Only (notes)
  static final int DATABASE_VERSION_LABELS = 2;    // Added: (labels), (notes_labels)


  NotesDatabaseOpenHelper(String name, SQLiteDatabase.CursorFactory factory, int version) {
    super(NotesApplication.getContext(), name, factory, version);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    createFirstVersion(db);
    upgradeToLabels(db, true);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    AppLog.d(LOG_TAG, "Upgrading version " + oldVersion + " to " + newVersion);

    if (oldVersion == DATABASE_VERSION_FIRST && newVersion == DATABASE_VERSION_LABELS) {
      upgradeToLabels(db, false);
    }
  }

  private void createFirstVersion(SQLiteDatabase db) {
    db.execSQL(NotesDatabaseAdapter.CREATE_NOTES_TABLE);
    AppLog.d(LOG_TAG, "Schema creation: " + NotesDatabaseAdapter.CREATE_NOTES_TABLE);
  }

  private void upgradeToLabels(SQLiteDatabase db, boolean creation) {
    db.execSQL(NotesDatabaseAdapter.CREATE_LABELS_TABLE);
    db.execSQL(NotesDatabaseAdapter.CREATE_NOTES_LABELS_TABLE);
    AppLog.d(LOG_TAG, (creation ? "Schema creation: " : "Schema upgrading: ") + NotesDatabaseAdapter.CREATE_LABELS_TABLE);
    AppLog.d(LOG_TAG, (creation ? "Schema creation: " : "Schema upgrading: ") + NotesDatabaseAdapter.CREATE_NOTES_LABELS_TABLE);
  }
}




Java Source Code List

com.iliakplv.notes.NotesApplication.java
com.iliakplv.notes.analytics.EventTracker.java
com.iliakplv.notes.analytics.Event.java
com.iliakplv.notes.gui.main.MainActivityTest.java
com.iliakplv.notes.gui.main.MainActivity.java
com.iliakplv.notes.gui.main.NavigationDrawerFragment.java
com.iliakplv.notes.gui.main.NoteDetailsFragment.java
com.iliakplv.notes.gui.main.NotesListFragment.java
com.iliakplv.notes.gui.main.dialogs.AboutDialog.java
com.iliakplv.notes.gui.main.dialogs.AbstractItemDialog.java
com.iliakplv.notes.gui.main.dialogs.DropboxAccountLinkingDialog.java
com.iliakplv.notes.gui.main.dialogs.LabelEditDialog.java
com.iliakplv.notes.gui.main.dialogs.NoteLabelsDialog.java
com.iliakplv.notes.gui.main.dialogs.SimpleItemDialog.java
com.iliakplv.notes.gui.main.dialogs.VoiceSearchInstallDialog.java
com.iliakplv.notes.gui.settings.SettingsActivity.java
com.iliakplv.notes.notes.AbstractNote.java
com.iliakplv.notes.notes.LabelComparator.java
com.iliakplv.notes.notes.Label.java
com.iliakplv.notes.notes.NoteComparator.java
com.iliakplv.notes.notes.NotesUtils.java
com.iliakplv.notes.notes.TextNote.java
com.iliakplv.notes.notes.db.NotesDatabaseAdapter.java
com.iliakplv.notes.notes.db.NotesDatabaseOpenHelper.java
com.iliakplv.notes.notes.db.NotesDatabaseStorage.java
com.iliakplv.notes.notes.dropbox.DropboxHelper.java
com.iliakplv.notes.notes.dropbox.NotesDropboxStorage.java
com.iliakplv.notes.notes.storage.NotesStorageListener.java
com.iliakplv.notes.notes.storage.NotesStorage.java
com.iliakplv.notes.notes.storage.StorageDataTransfer.java
com.iliakplv.notes.notes.storage.StorageWrapper.java
com.iliakplv.notes.notes.storage.Storage.java
com.iliakplv.notes.storage.StorageTest.java
com.iliakplv.notes.utils.AppLog.java
com.iliakplv.notes.utils.ConnectivityUtils.java
com.iliakplv.notes.utils.StringUtils.java
com.iliakplv.notes.utils.Utils.java