Android Open Source - game_guess_lib Guess Game B D D Handler






From Project

Back to project page game_guess_lib.

License

The source code is released under:

MIT License

If you think the Android project game_guess_lib 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.wkmf.guess.lib.data;
//from  w w w  . j a  v  a  2s .  co  m
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;

import com.wkmf.guess.lib.common.api.GuessApi;
import com.wkmf.guess.lib.structure.GuessGame;
import com.wkmf.lib.bdd.E_BDDHandler;

/**
 * Created by ernestofndz on 9/02/14.
 */
public class GuessGameBDDHandler extends E_BDDHandler {

    public static final String tableName = "BDDGG"; // tabla
    private GuessSQL sql;

    // constructor
    public GuessGameBDDHandler(Context context, String bddName) {
        super(context, bddName);
    }

    @Override
    public void initialize() {
        // abrimos la base de datos en modo escritura
        this.sql = new GuessSQL(getContext(), getBddName(), null, 1);
    }

    // intentamos recuperar los datos de bdd, concretamente el json
    public GuessGame getGuessGame() {
        GuessGame guessGame = null;
        // sql
        String query = "SELECT * FROM " + tableName;
        // hacemos la consulta
        Cursor c = this.getBdd().select(sql.getReadableDatabase(), query);
        try {
            if (c.moveToFirst()) {
                // recuperamos el json y lo convertimos en objeto
                guessGame = GuessApi.fromJsonGuessGame(c.getString(1));
            }
        } finally {
            // cerramos la conex
            c.close();
            getBdd().close();
        }
        // devolvemos el objeto
        return guessGame;
    }

    // guardamos el objeto
    public void insert(GuessGame guessGame) {
        this.getBdd().insert(this.sql.getWritableDatabase(), tableName, getContentValues(guessGame));
    }

    // modificamos el objeto
    public void update(GuessGame guessGame) {
        this.getBdd().update(this.sql.getWritableDatabase(), tableName, getContentValues(guessGame), "ID=".concat(guessGame.getAppId()));
    }

    // borramos el objeto
    public void delete(GuessGame guessGame) {
        this.getBdd().delete(this.sql.getWritableDatabase(), tableName, "ID=".concat(guessGame.getAppId()));
    }

    // obtenemos el content values
    private ContentValues getContentValues(GuessGame guessGame) {
        ContentValues values = new ContentValues();
        values.put("ID", guessGame.getAppId());
        values.put("VALUE", GuessApi.toJsonGuessGame(guessGame));
        return values;
    }
}




Java Source Code List

com.android.vending.billing.util.Base64DecoderException.java
com.android.vending.billing.util.Base64.java
com.android.vending.billing.util.IabException.java
com.android.vending.billing.util.IabHelper.java
com.android.vending.billing.util.IabResult.java
com.android.vending.billing.util.Inventory.java
com.android.vending.billing.util.Purchase.java
com.android.vending.billing.util.Security.java
com.android.vending.billing.util.SkuDetails.java
com.wkmf.guess.lib.common.Constants.java
com.wkmf.guess.lib.common.ads.GuessGameAdsListener.java
com.wkmf.guess.lib.common.ads.GuessGameAds.java
com.wkmf.guess.lib.common.api.GuessApi.java
com.wkmf.guess.lib.common.api.GuessRestApi.java
com.wkmf.guess.lib.common.async.DownloadTask.java
com.wkmf.guess.lib.common.dialog.DialogElement.java
com.wkmf.guess.lib.common.dialog.DialogModalListAdapter.java
com.wkmf.guess.lib.common.dialog.DialogModal.java
com.wkmf.guess.lib.data.GuessGameBDDHandler.java
com.wkmf.guess.lib.data.GuessSQL.java
com.wkmf.guess.lib.impl.GuessGameBaseApp.java
com.wkmf.guess.lib.impl.GuessGameImageDownload.java
com.wkmf.guess.lib.impl.GuessGameInterface.java
com.wkmf.guess.lib.purchase.items.GuessGameItems.java
com.wkmf.guess.lib.screen.GuessLevelScreen.java
com.wkmf.guess.lib.screen.GuessMainScreen.java
com.wkmf.guess.lib.screen.GuessQuestionScreen.java
com.wkmf.guess.lib.screen.adapter.LevelsAdapter.java
com.wkmf.guess.lib.screen.adapter.QuestionsAdapter.java
com.wkmf.guess.lib.service.GuessGameService.java
com.wkmf.guess.lib.service.GuessGameUpdater.java
com.wkmf.guess.lib.service.ServiceStarter.java
com.wkmf.guess.lib.structure.GuessConfig.java
com.wkmf.guess.lib.structure.GuessDrawable.java
com.wkmf.guess.lib.structure.GuessGame.java
com.wkmf.guess.lib.structure.GuessLevelType.java
com.wkmf.guess.lib.structure.GuessLevel.java
com.wkmf.guess.lib.structure.GuessQuestion.java