一、环境
当程序卸载了,android设备里面的数据库还能够保存吗?
在实际应用过程中,可能会出现这个问题。我需要更新应用,导致数据库里面的资料都没了。这个时候我们需要把数据保存到SD卡中,这样,就避免了数据的流失。
二、代码
package com.xs.laizhen.visit.greendao;
import android.content.Context;
import android.content.ContextWrapper;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.text.TextUtils;
import android.util.Log;
import com.xs.laizhen.visit.base.MyApplicaion;
import com.xs.laizhen.visit.utils.CommonUtils;
import java.io.File;
import java.io.IOException;
/**
* 类名称:GreenDaoContext
* 创建者:Create by laizhen
* 创建时间:Create on 2018/1/31
* 描述:主要用于基于GreenDao框架自定义数据库路径
*/
public class GreenDaoContext extends ContextWrapper {
private String currentUserId = "greendao";//一般用来针对一个用户一个数据库,以免数据混乱问题
private Context mContext;
public GreenDaoContext() {
super(MyAp