首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

db数据库的处置

2012-08-22 
db数据库的处理final String DB_DESTINATION /data/data/YOUR_PACKAGE_NAME/databases/MyDatabaseFile.

db数据库的处理

final String DB_DESTINATION = "/data/data/YOUR_PACKAGE_NAME/databases/MyDatabaseFile.db";?
?
// Check if the database exists before copying?
boolean initialiseDatabase = (new File("DB_DESTINATION")).exists();?
if (initialiseDatabase == true) {?
?
? ? // Open the .db file in your assets directory?
? ? InputStream is = getContext().getAssets().open("MyDatabaseFile.db");?
?
? ? // Copy the database into the destination?
? ? OutputStream os = new FileOutputStream(DB_DESTINATION);?
? ? byte[] buffer = new byte[1024];?
? ? int length;?
? ? while ((length = is.read(buffer)) > 0){?
? ? ? ? os.write(buffer, 0, length);?
? ? }?
? ? os.flush();?
?
? ? os.close();?
? ? is.close();?
}?

热点排行