Android Open Source - ProjectStudio D B Manager






From Project

Back to project page ProjectStudio.

License

The source code is released under:

Apache License

If you think the Android project ProjectStudio 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 DB_Provider;
//from w w  w. j a v  a2  s  .  com
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by desmond on 1/23/14.
 */
public class DBManager extends SQLiteOpenHelper {

    private static String DATABASE_NAME = "UtilDB.db";
    private static int DATABASE_VERSION = 1;

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

    public DBManager(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, DATABASE_NAME, factory, DATABASE_VERSION);
    }

    //CALLED ONLY WHEN NO DATABASE EXISTS IN DISK AND THE
    //HELPER CLASS NEEDS TO CREATE A NEW ONE
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DB_ABSTRACTS.DBProfessor.CREATE_TABLE);
        db.execSQL(DB_ABSTRACTS.DBCourse.CREATE_TABLE);
        db.execSQL(DB_ABSTRACTS.DBTasks.CREATE_TABLE);
    }

    //CALLED WHEN THERE IS A DATABAS VERSION MISMATCH MEANING THAT
    //THE VERSION OF THE DATABASE ON DISK NEEDS TO BE UPGRADED TO THE
    //CURRENT VERSION
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //Log the version upgrade
        Log.w("DBUPGRADE", "UPGRADING FROM VERSION " + oldVersion +
                " TO " + newVersion + ", which will destroy all old date");

        //UPGRADE THE EXISTING DATABASE TO CONFORM TO THE NEW VERSION.
        //MULTIPLE PREVIOUS VERSIONS CAN BE HANDLED BY COMPARING OLD VERSIONS
        //AND NEW VERSIONS VALUES

        //THE SIMPLEST CASE IS TO DROP THE OLD TABLE AND CREATE A NEW ONE
        db.execSQL(DB_ABSTRACTS.DBProfessor.DELETE_TABLE);
        db.execSQL(DB_ABSTRACTS.DBCourse.DELETE_TABLE);
        db.execSQL(DB_ABSTRACTS.DBTasks.DELETE_TABLE);
        onCreate(db);
    }
}




Java Source Code List

DB_Provider.CourseDataSource.java
DB_Provider.DBManager.java
DB_Provider.DB_ABSTRACTS.java
DB_Provider.ProfessorDataSource.java
DB_Provider.TaskDataSource.java
Drawables.DrawableAlignedButton.java
FontPackage.TypefaceSpan.java
adapters.CourseCardAdapter.java
adapters.ExamsPassedCardAdapter.java
adapters.ExamsPendingCardAdapter.java
adapters.Exams_TabsPagerAdapter.java
adapters.HomeCardAdapter.java
adapters.MatesCardAdapter.java
adapters.NavDrawerListAdapter.java
adapters.ProfessorCardAdapter.java
adapters.TaskCardAdapter.java
adapters.TasksTabPagerAdapter.java
com.example.uniutilproject.BuildConfig.java
com.example.uniutilproject.UniUtil_MainActivity.java
days_fragments.FridayTaskFragment.java
days_fragments.MondayTaskFragment.java
days_fragments.SaturdayTaskFragment.java
days_fragments.SundayTaskFragment.java
days_fragments.ThursdayTaskFragment.java
days_fragments.TuesdayTaskFragment.java
days_fragments.WednesdayTaskFragment.java
dialog_fragments.DatePickerDialogFragment.java
dialog_fragments.MatesDialogFragment.java
dialog_fragments.ProfessorsDialogFragment.java
dialog_fragments.TimePickerDialogFragment.java
fragments.AddCourseFragment.java
fragments.AddProfFragment.java
fragments.AddTaskFragment.java
fragments.CoursesFragment.java
fragments.CursorLoaderListFragment.java
fragments.ExamsFragment.java
fragments.ExamsPassedFragment.java
fragments.ExamsPendingFragment.java
fragments.HomeFragment.java
fragments.MatesFragment.java
fragments.ProfessorsFragment.java
fragments.StudyPlanFragment.java
fragments.TasksFragment.java
fragments.UpdateCourseFragment.java
fragments.UpdateProfessorFragment.java
interfaces.NoticeDialogListener.java
interfaces.package-info.java
model.Course.java
model.Days.java
model.MyParcelable.java
model.NavDrawerItem.java
model.Professor.java
model.Task.java