public class ConfigurationUtil {
//存库
private static SetDao setDao = new SetDao();
//设置对象
private Configuration configuration;
/**
* 查询SQLite数据库configuration中的数据
* @return
*/
public static Configuration findConfigurationByDateBase() {
SQLiteDatabase db = VLCApplication.getAppContext().openOrCreateDatabase(DATANAME, VLCApplication.getAppContext().MODE_PRIVATE, null);
setDao.setDb(db);
Configuration configuration = setDao.findConfiguration();
return configuration;
}
/**
* 设置完成后将configuration保存到本地库中
*/
private void saveConfigurationToDataBase() {
try {
Configuration configuration = (Configuration) InstanceServiceUtil.createInstance(Configuration.class.toString());
SQLiteDatabase db = VLCApplication.getAppContext().openOrCreateDatabase(DATANAME, VLCApplication.getAppContext().MODE_PRIVATE, null);
setDao.setDb(db);
setDao.deleteAll();
setDao.insert(configuration);
Configuration conf = setDao.findConfiguration();
System.out.println(conf);
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateConfiguration(Configuration conf) {
if(null != conf) {
configuration.setDimage_uri(conf.getDimage_uri());
configuration.setDpay_uri(conf.getDpay_uri());
configuration.setDcloud_uri(conf.getDcloud_uri());
configuration.setDin_uri(conf.getDin_uri());
configuration.setDversioncode_uri(conf.getDversioncode_uri());
}
InstanceServiceUtil.writeMap(Configuration.class.toString(),configuration);
}
}
网友评论