http://www.eoeandroid.com/thread-257614-1-1.html
把数据库db文件放在了sd卡中,和apk在不同的文件夹里,但是,每次apk更新之后,原来的数据都没有了 我很郁闷 代码如下: private File path = new File("/sdcard/yangzhao");// 创建目录 private File f = new File("/sdcard/yangzhao/"+DATABASE_NAME);// 创建文件 public DBUtil(Context myContext) { try { if(!path.exists()){ path.mkdirs(); } if(!f.exists()){ try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } db = SQLiteDatabase.openOrCreateDatabase(f,null); CreateTable(); } catch (IllegalStateException illegalstateexception) { Log.v(TAG, illegalstateexception.getMessage()); } Log.v("DBUtil", (new StringBuilder("db path=")).append(db.getPath()) .toString()); } |
是否是 你每次都新建数据库 覆盖了? |