//SD卡根目录
String DATABASE_PATH = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
try{
//复制后在SD卡中的文件名是dataBase
String databaseFilename = DATABASE_PATH + "/SYIMS/dataBase.db";
File dir = new File(DATABASE_PATH);
if (!dir.exists())
dir.mkdir();
if (!(new File(databaseFilename)).exists()){
InputStream is = getResources().openRawResource(R.raw.database);
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){
e.printStackTrace();
}