package tmi.li.txwidgets.txclck;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.util.Log;
import tmi.li.txwidgets.Widget;
public class TxClckWidget extends Widget {
private static final String TAG = "tmi.li.txwidgets.txwthr.TxWthrWidget";
private Context context;
public String _format;
private DBAdapter db;
public TxClckWidget(Context context) {
this.context = context;
}
protected void finalize() {
try {
db.close();
}catch(Exception e) {
}
}
public boolean save() {
db = new DBAdapter(context);
db.insertWidget(this);
db.close();
return true;
}
public boolean update() {
db = new DBAdapter(context);
boolean test = db.updateWidget(this);
db.close();
return test;
}
public void deleteWidget() {
db = new DBAdapter(context);
db.deleteWidget(this);
db.close();
}
public boolean load(int id){
try {
db = new DBAdapter(context);
Cursor s = db.getWidget(id);
_id = s.getInt(0);
_flcolor = s.getString(1);
_ftcolor = s.getString(2);
_fbcolor = s.getString(3);
_bcolor = s.getString(4);
_appname = s.getString(5);
_format = s.getString(6);
s.close();
db.close();
return true;
}catch(SQLException e) {
//e.printStackTrace();
return false;
}catch(Exception e) {
//e.printStackTrace();
return false;
}
}
public ContentValues getValues() {
ContentValues values = new ContentValues();
values.put(DBAdapter.ID, _id);
values.put(DBAdapter.FLCOLOR, _flcolor);
values.put(DBAdapter.FTCOLOR, _ftcolor);
values.put(DBAdapter.FBCOLOR, _fbcolor);
values.put(DBAdapter.BCOLOR, _bcolor);
values.put(DBAdapter.APPNAME, _appname);
values.put(DBAdapter.FORMAT, _format);
return values;
}
public void logWidget() {
Log.d(TAG, "id\t=>\t"+_id);
Log.d(TAG, "FLCOLOR\t=>\t"+_flcolor);
Log.d(TAG, "FTCOLOR\t=>\t"+_ftcolor);
Log.d(TAG, "FBCOLOR\t=>\t"+_fbcolor);
Log.d(TAG, "BCOLOR\t=>\t"+_bcolor);
Log.d(TAG, "APPNAME\t=>\t"+_appname);
Log.d(TAG, "FORMAT\t=>\t"+_format);
}
}
|