android读取apk中已经存在的数据库信息

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);


你可能感兴趣的:(android读取apk中已经存在的数据库信息)