http://www.oschina.net/code/snippet_145944_11646
String databaseFilename = DATABASE_PATH + "/" + DATABASE_NAME; File dir = new File(DATABASE_PATH); if (!dir.exists()) dir.mkdir(); if (!(new File(databaseFilename)).exists()) { InputStream is = context.getResources().openRawResource(R.raw.jobexam); 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(); } db = SQLiteDatabase.openOrCreateDatabase(databaseFilename, null);
时间: 2024-11-04 02:44:48