Android Open Source - MinerStatus Config Service Impl From Project Back to project page MinerStatus .
License The source code is released under:
Apache License
If you think the Android project MinerStatus 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 me.davidgreene.minerstatus.service;
/ * w w w . j a v a 2 s . c o m * /
import me.davidgreene.minerstatus.MinerStatusApp;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class ConfigServiceImpl implements ConfigService {
private MinerStatusApp app;
public ConfigServiceImpl(Context context){
this.app = ((MinerStatusApp)context);
}
private final String SELECT_CONFIG_VALUE = "select value from config where key=?" ;
@Override
public String getConfigValue(String key) {
Cursor cursor = null;
try {
cursor = getDBr().rawQuery(SELECT_CONFIG_VALUE, new String[]{key});
if (cursor.moveToNext()){
return cursor.getString(0);
} else {
return null;
}
} catch (Exception e){
return null;
} finally {
if (cursor != null){
cursor.close();
}
}
}
@Override
public void setConfigValue(String key, String value) {
deleteConfigValue(key);
ContentValues values = new ContentValues();
values.put("key" , key);
values.put("value" , value);
getDBw().insert("config" , null, values);
}
@Override
public void deleteConfigValue(String key) {
getDBw().delete("config" , "key=?" , new String[]{key});
}
private SQLiteDatabase getDBw(){
return app.getDbHelper().getWritableDatabase();
}
private SQLiteDatabase getDBr(){
return app.getDbHelper().getReadableDatabase();
}
}
Java Source Code List me.davidgreene.minerstatus.AbstractMinerStatusActivity.java me.davidgreene.minerstatus.AddMinerActivity.java me.davidgreene.minerstatus.MainMinerActivity.java me.davidgreene.minerstatus.MinerStatusApp.java me.davidgreene.minerstatus.OptionsActivity.java me.davidgreene.minerstatus.ViewMinerActivity.java me.davidgreene.minerstatus.beans.BitpoolPool.java me.davidgreene.minerstatus.beans.BitpoolStatus.java me.davidgreene.minerstatus.beans.BitpoolUser.java me.davidgreene.minerstatus.beans.BtcMine.java me.davidgreene.minerstatus.beans.BtcguildPool.java me.davidgreene.minerstatus.beans.BtcguildStatus.java me.davidgreene.minerstatus.beans.BtcguildUser.java me.davidgreene.minerstatus.beans.BtcguildWorker.java me.davidgreene.minerstatus.beans.DeepbitStatus.java me.davidgreene.minerstatus.beans.MtGox.java me.davidgreene.minerstatus.beans.Result.java me.davidgreene.minerstatus.beans.SlushStatus.java me.davidgreene.minerstatus.beans.Status.java me.davidgreene.minerstatus.beans.Ticker.java me.davidgreene.minerstatus.beans.WorkerStatus.java me.davidgreene.minerstatus.beans.Worker.java me.davidgreene.minerstatus.service.ConfigServiceImpl.java me.davidgreene.minerstatus.service.ConfigService.java me.davidgreene.minerstatus.service.MinerServiceImpl.java me.davidgreene.minerstatus.service.MinerService.java me.davidgreene.minerstatus.service.ThemeServiceImpl.java me.davidgreene.minerstatus.service.ThemeService.java me.davidgreene.minerstatus.theme.DarkTheme.java me.davidgreene.minerstatus.theme.LightTheme.java me.davidgreene.minerstatus.theme.ThemeFactory.java me.davidgreene.minerstatus.theme.Theme.java me.davidgreene.minerstatus.util.AsynchMinerUpdateThread.java me.davidgreene.minerstatus.util.DbOpenHelper.java me.davidgreene.minerstatus.util.MinerStatusConstants.java me.davidgreene.minerstatus.util.StatusObjectFactory.java