Android Open Source - ExampleApp Data Base Helper






From Project

Back to project page ExampleApp.

License

The source code is released under:

Copyright (c) 2014, Altinn All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redis...

If you think the Android project ExampleApp 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.altinn.apps.fisher.db;
/*from www.  ja v a2s  . c o m*/
/**
 * This is a ParentHelper class
 * All kind of helper class can be initiated from here and respective helper can be generated
 * Respective helper will work on respective table operation(delete/insert/update/search etc).
 * 
 */


import java.util.ArrayList;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.altinn.apps.fisher.AppContext;



public class DataBaseHelper extends SQLiteOpenHelper {
  public static final String DB_PATH = "/data/data/com.altinn.apps.fisher/databases/";
  private static DataBaseHelper instance;
  public static final String DB_NAME = "fisher_app.db";
  private static final int DB_VERSION = 1;
  private final Context myContext;
  private FormDBHelper mFormDBHelper;
  private FactoryDBHelper mFactoryDBHelper;
  private FishCategoryDBHelper mFishDBHelper;//Not in use
  private VesselDBHelper mVesselDBHelper;//Not in use
  private RegsDBHelper mRegsDBHelper;//Not in use
  public static final int TABLE_HEPLER_FORM = 100;
  public static final int TABLE_HEPLER_FACTORY = 101;
  public static final int TABLE_HEPLER_FISH_CATEGORY = 102;
  public static final int TABLE_HEPLER_SHIP_NAME = 103;
  public static final int TABLE_HEPLER_REGS_NUMBER = 104;
  
  private ArrayList<IDBHelper> mHelperList;

  private DataBaseHelper(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
    this.myContext = context;
    
    mHelperList = new ArrayList<IDBHelper>();
    initHelpers();
  }
  
  private void initHelpers(){
    mFormDBHelper = new FormDBHelper();
    mHelperList.add(mFormDBHelper);
    
    mFactoryDBHelper = new FactoryDBHelper();
    mHelperList.add(mFactoryDBHelper);
    
    mFishDBHelper = new FishCategoryDBHelper();
    mHelperList.add(mFishDBHelper);
    
    mVesselDBHelper = new VesselDBHelper();
    mHelperList.add(mVesselDBHelper);
    
    mRegsDBHelper = new RegsDBHelper();
    mHelperList.add(mRegsDBHelper);
  }
  
  
  
  public IDBHelper getDBHelper(int tableHelper){
    IDBHelper helper = null;
    switch(tableHelper){
    case TABLE_HEPLER_FORM:
      helper = mFormDBHelper;
      break;
    case TABLE_HEPLER_FACTORY:
      helper = mFactoryDBHelper;
      break;
      
    case TABLE_HEPLER_FISH_CATEGORY:
      helper = mFishDBHelper;
      break;
      
    case TABLE_HEPLER_SHIP_NAME:
      helper = mVesselDBHelper;
      break;
      
    case TABLE_HEPLER_REGS_NUMBER:
      helper = mRegsDBHelper;
      break;
    }
    return helper;
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
     for(IDBHelper helper:mHelperList){
       helper.onCreate(db);
     }
    
    
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
     for(IDBHelper helper:mHelperList){
       helper.onUpgrade(db,arg1,arg2);
     }
  }
  
  public static synchronized DataBaseHelper getInstance() {
    if(instance != null){
      return instance;
    } else{
      instance = new DataBaseHelper(AppContext.getInstance());
      return instance;
    }
  }
  


}




Java Source Code List

com.altinn.apps.fisher.AppContext.java
com.altinn.apps.fisher.CacheManager.java
com.altinn.apps.fisher.common.AppConstants.java
com.altinn.apps.fisher.common.IStatusMessage.java
com.altinn.apps.fisher.common.MenuItem.java
com.altinn.apps.fisher.common.StatusMessage.java
com.altinn.apps.fisher.db.DataBaseHelper.java
com.altinn.apps.fisher.db.FactoryDBHelper.java
com.altinn.apps.fisher.db.FishCategoryDBHelper.java
com.altinn.apps.fisher.db.FormDBHelper.java
com.altinn.apps.fisher.db.IDBHelper.java
com.altinn.apps.fisher.db.RegsDBHelper.java
com.altinn.apps.fisher.db.VesselDBHelper.java
com.altinn.apps.fisher.gps.CLocationProvider.java
com.altinn.apps.fisher.gps.ILocationUpdateListner.java
com.altinn.apps.fisher.models.CaughtInfoData.java
com.altinn.apps.fisher.models.InfoData.java
com.altinn.apps.fisher.models.ReportInfoData.java
com.altinn.apps.fisher.models.UserProfile.java
com.altinn.apps.fisher.net.AbstractWorkerTask.java
com.altinn.apps.fisher.net.CookieHelper.java
com.altinn.apps.fisher.net.IParser.java
com.altinn.apps.fisher.net.JSParser.java
com.altinn.apps.fisher.net.ParseManager.java
com.altinn.apps.fisher.net.TaskNotifier.java
com.altinn.apps.fisher.net.jsobj.AttachmentObj.java
com.altinn.apps.fisher.net.jsobj.FormObj.java
com.altinn.apps.fisher.net.jsobj.JSConstants.java
com.altinn.apps.fisher.net.jsobj.JsonObj.java
com.altinn.apps.fisher.net.jsobj.LinkItemObj.java
com.altinn.apps.fisher.net.jsobj.LinkObj.java
com.altinn.apps.fisher.net.jsobj.MessageObj.java
com.altinn.apps.fisher.net.jsobj.MessagesEmbedded.java
com.altinn.apps.fisher.net.jsobj.OrganisationObj.java
com.altinn.apps.fisher.net.tasks.LoginTask.java
com.altinn.apps.fisher.net.tasks.RefreshTokenTask.java
com.altinn.apps.fisher.net.tasks.SendReportTask.java
com.altinn.apps.fisher.net.tasks.UserProfileTask.java
com.altinn.apps.fisher.settings.FactoryDetails.java
com.altinn.apps.fisher.settings.FishDetails.java
com.altinn.apps.fisher.settings.SettingItem.java
com.altinn.apps.fisher.settings.VesselsDetails.java
com.altinn.apps.fisher.ui.component.DurationTimePickDialog.java
com.altinn.apps.fisher.ui.component.RAutoCompleteTextView.java
com.altinn.apps.fisher.ui.component.RButton.java
com.altinn.apps.fisher.ui.component.REditText.java
com.altinn.apps.fisher.ui.component.RTextView.java
com.altinn.apps.fisher.ui.screen.BaseActivity.java
com.altinn.apps.fisher.ui.screen.BrowserActivity.java
com.altinn.apps.fisher.ui.screen.FactoryDetailsActivity.java
com.altinn.apps.fisher.ui.screen.HomeActivity.java
com.altinn.apps.fisher.ui.screen.InformationActivity.java
com.altinn.apps.fisher.ui.screen.MenuNavigationActivity.java
com.altinn.apps.fisher.ui.screen.ReportActivity.java
com.altinn.apps.fisher.ui.screen.ReportReceivedFishActivity.java
com.altinn.apps.fisher.ui.screen.ReportSendDetailActivity.java
com.altinn.apps.fisher.ui.screen.SplashActivity.java
com.altinn.apps.fisher.ui.screen.UserProfileActivity.java
com.altinn.apps.fisher.utils.PreferenceUtils.java
com.altinn.apps.fisher.utils.Utils.java
net.simonvt.menudrawer.BuildLayerFrameLayout.java
net.simonvt.menudrawer.ColorDrawable.java
net.simonvt.menudrawer.DraggableDrawer.java
net.simonvt.menudrawer.FloatScroller.java
net.simonvt.menudrawer.MenuDrawer.java
net.simonvt.menudrawer.NoClickThroughFrameLayout.java
net.simonvt.menudrawer.OverlayDrawer.java
net.simonvt.menudrawer.PeekInterpolator.java
net.simonvt.menudrawer.Position.java
net.simonvt.menudrawer.Scroller.java
net.simonvt.menudrawer.SinusoidalInterpolator.java
net.simonvt.menudrawer.SlideDrawable.java
net.simonvt.menudrawer.SlidingDrawer.java
net.simonvt.menudrawer.SmoothInterpolator.java
net.simonvt.menudrawer.StaticDrawer.java
net.simonvt.menudrawer.ViewHelper.java
net.simonvt.menudrawer.compat.ActionBarHelperCompat.java
net.simonvt.menudrawer.compat.ActionBarHelperNative.java
net.simonvt.menudrawer.compat.ActionBarHelper.java