asset Æú´õ¿¡ ¿øº»db¸¦ ³Ö¾îµÎ°í ¾Æ·¡ ¼Ò½º¿Í °°ÀÌ ÇÏ¸é ¿¡¹Ä¿¡¼´Â db°¡ º¸À̴µ¥ ¿Ö Æù¿¡¼´Â ¿¡·¯°¡ ³ª´ÂÁö ¾Ë ¼ö°¡ ¾ø³×¿ä. ·çÆÃÀ̶ó´Â °ÍÀÌ ÇÊ¿äÇÑ °Ç°¡¿ä?
±×¸®°í ¸¸¾à ·çÆÃÀ» ÇØ¾ß µÈ´Ù¸é, ÀÌ ¾ÛÀ» »ç¿ëÇÒ·Á¸é ¸ðµç »ç¿ëÀÚµéÀÌ ·çÆÃÀ» ÇؾßÇմϱî?
public static void initialize(Context ctx) {
// check
File folder = new File(ROOT_DIR + "databases");
folder.mkdirs();
File outfile = new File(ROOT_DIR + "databases/" + DATABASE_NAME);
if (outfile.length() <= 0) {
AssetManager assetManager = ctx.getResources().getAssets();
try {
InputStream is = assetManager.open(DATABASE_NAME, AssetManager.ACCESS_BUFFER);
long filesize = is.available();
byte [] tempdata = new byte[(int)filesize];
is.read(tempdata);
is.close();
outfile.createNewFile();
FileOutputStream fo = new FileOutputStream(outfile);
fo.write(tempdata);
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)