Android自界说Sqlite数据库地位
来源:长沙北大青鸟新途|发布时间:2016-05-21|浏览量:
* @Title: changeDatabasesDir * @Des cription: TODO: Change default location of sqlite databases. * @param @param mContext * @return void * @throws public static void changeDatabasesDir(Context mContext) { try { Field field; field = ContextWrapper.class.getDeclaredField("mBase"); field.setAccessible(true); // 取得mBase变量 Object obj = field.get(mContext); field = obj.getClass().getDeclaredField("mDatabasesDir"); field.setAccessible(true); // 树立自界说途径 File file = new File(Path.DATABASES); field.set(obj, file); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block MyLog.e(e.toString()); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block MyLog.e(e.toString()); } catch (IllegalAccessException e) { // TODO Auto-generated catch block MyLog.e(e.toString()); }上一篇:Android瀑布流照片墙完成,体验不法则摆列的美感
扫码关注微信公众号了解更多详情
跟技术大咖,专业导师一起交流学习