美文网首页
使用该数据表的工具类

使用该数据表的工具类

作者: d655059c22cc | 来源:发表于2017-09-27 15:44 被阅读0次
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);
    }
}

相关文章

网友评论

      本文标题:使用该数据表的工具类

      本文链接:https://www.haomeiwen.com/subject/uepuextx.html