Android Open Source - on-the-hook Database Manager






From Project

Back to project page on-the-hook.

License

The source code is released under:

MIT License

If you think the Android project on-the-hook 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.yoandinkov.onthehook.db;
//from  ww w .j a  v a2  s.  c  o  m
import java.sql.SQLException;
import java.util.List;

import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import com.yoandinkov.onthehook.db.models.FishDbModel;

import android.content.Context;

public class DatabaseManager {

    static private DatabaseManager instance;

    static public void init(Context ctx) {
        if (null==instance) {
            instance = new DatabaseManager(ctx);
        }
    }

    static public DatabaseManager getInstance() {
        return instance;
    }

    private DatabaseHelper helper;
    private DatabaseManager(Context ctx) {
        helper = new DatabaseHelper(ctx);
    }

    private DatabaseHelper getHelper() {
        return helper;
    }

    public List<FishDbModel> getAllFishesList() {
        List<FishDbModel> fishesList = null;
        try {
          fishesList = getHelper().getFishesListDao().queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return fishesList;
    }
    
    public void addFishToDb(FishDbModel currentFish) {
        try {
          getHelper().getFishesListDao().create(currentFish);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    
    public void clearFishesList() {
      getHelper().dropFishesTable();
    }
}




Java Source Code List

com.yoandinkov.onthehook.DraughtActivity.java
com.yoandinkov.onthehook.FishActivity.java
com.yoandinkov.onthehook.FishingActivity.java
com.yoandinkov.onthehook.LoginActivity.java
com.yoandinkov.onthehook.MainMenuActivity.java
com.yoandinkov.onthehook.RegisterActivity.java
com.yoandinkov.onthehook.RequestActivity.java
com.yoandinkov.onthehook.adapters.FishAdapter.java
com.yoandinkov.onthehook.crypt.JsonConverter.java
com.yoandinkov.onthehook.crypt.SHA1Converter.java
com.yoandinkov.onthehook.db.DatabaseHelper.java
com.yoandinkov.onthehook.db.DatabaseManager.java
com.yoandinkov.onthehook.db.models.FishDbModel.java
com.yoandinkov.onthehook.models.Coordinates.java
com.yoandinkov.onthehook.models.Credentials.java
com.yoandinkov.onthehook.models.FishButton.java
com.yoandinkov.onthehook.models.FishSpecies.java
com.yoandinkov.onthehook.models.Fish.java
com.yoandinkov.onthehook.models.Fishing.java
com.yoandinkov.onthehook.models.HttpResponseWrapper.java
com.yoandinkov.onthehook.models.HttpType.java
com.yoandinkov.onthehook.models.Login.java
com.yoandinkov.onthehook.models.NewFishing.java
com.yoandinkov.onthehook.models.Registration.java
com.yoandinkov.onthehook.models.RequestPurpose.java
com.yoandinkov.onthehook.models.Response.java
com.yoandinkov.onthehook.models.WaterLocation.java