清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
把数据库文件放在res/raw下 貌似android 的raw下视不会被编译成二进制的。然后一运行程序就判断是否存在数据库表不存在则通过输入输出流复制raw下的数据库文件到手机中.代码如下
try { Log.e(DATABASE_PATH, DATABASE_PATH); String databaseFilename = DATABASE_PATH + "/" + DATABASE_FILENAME; File dir = new File(DATABASE_PATH); if (!dir.exists()) dir.mkdir(); if (!(new File(databaseFilename)).exists()) { InputStream is = getResources().openRawResource( R.raw.healthmanage); FileOutputStream fos = new FileOutputStream(databaseFilename); byte[] buffer = new byte[8192]; int count = 0; while ((count = is.read(buffer)) > 0) { fos.write(buffer, 0, count); } fos.close(); is.close(); } } catch (Exception e) { Log.e("出错了", "出错了"); }