日期:2014-05-16 浏览次数:20406 次
public boolean extractDatabase(String dbfile) { try { if (new File(dbfile).exists()) { return true; } InputStream is = this.context.getResources().openRawResource( R.raw.models); try { FileOutputStream fos = new FileOutputStream(dbfile); try { byte[] buffer = new byte[BUFFER_SIZE]; int count = 0; while ((count = is.read(buffer)) > 0) { fos.write(buffer, 0, count); fos.flush(); } } finally { fos.close(); } } finally { is.close(); } return true; } catch (FileNotFoundException e) { Log.e("Database", "File not found"); } catch (IOException e) { Log.e("Database", "IO exception"); } return false; }
sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase( DB_LOCATION, null); sqLiteDatabase.rawQuery(expression, params);