½Ã°£Ç¥ Á¦ÀÛÇϱ¸Àִµ¥¿ä
°ø°³µÈ ½Ã°£Ç¥ ¾îÇà DB¸¦ °¡Áö°í¿Í¼
assets/database¿¡ ³Ö¾ù±¸¿ä
ÄÚµù¿¡¼
try {
db_create(); // assets/databaseÆú´õ¿¡ ÀÖ´Â dbÆÄÀÏÀ» ÇöÀç AVD¿¡ ¼³Ä¡
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); // ¿¡·¯½Ã ÇÁ¸°Æ®
}
À̰͵µÇÏ°í
private void db_create() throws IOException{
File folder = new File("/data/data/abc.prj1/databases/");
folder.mkdirs();
File outfile = new File("/data/data/abc.prj1/databases/table.db");
AssetManager am = getResources().getAssets();
InputStream is = am.open("database/table.db", AssetManager.ACCESS_BUFFER);
long filesize = is.available();
if(outfile.length() < filesize){
byte[] data = new byte[(int)filesize];
is.read(data);
is.close();
outfile.createNewFile();
FileOutputStream fos = new FileOutputStream(outfile);
fos.write(data);
fos.close();
}
}
ÀÌ·¸°Ô Ç߰ŵç¿ä. À̺κÐÀº
°ø°³µÈ ½Ã°£Ç¥ ¾îÇà ¿¡¼ ±×´ë·Î °¡Á®¿Ó¾î¿ä ÇÁ·ÎÁ§Æ®À̸§Àº ¹Ù²Ù°í..
±×¸®°í ³ªÁß¿¡ db¿¡ Á¢±ÙÇÒ¶§¿¡ ÀÌŬ¸³½º´Â ¿À·ù°¡ ¾ø´Âµ¥
ÆùÀ¸·Î µð¹ö±ëµµÁß¿¡, dbÁ¢±Ù¿¡¼¸¸ ¿¹±âÄ¡¸øÇÑ ¿À·ù°¡ »ý±â³×¿ä.
cursor = sql_db.rawQuery("select * from TimeTable", null);
ÀÌ·¸°Ô select³ª insertµî db¿¡ º»°ÝÀûÀ¸·Î Á¢±ÙÇÏ·ÁÇÒ¶§
Æù¿¡¼´Â ¿À·ù°¡ ³ª´Âµ¥¿ä...
¾î¶»°Ô ÇؾßÇÏ´ÂÁö ¹æÇâÁ» Àâ¾ÆÁÖ½Ã¸é °¨»çÇÕ´Ï´Ù. ¤Ð¤Ð
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)