public class MySQLiteOpenHelper extends SQLiteOpenHelper {
static String NAME = "testdb.sqlite";
static CursorFactory FACTORY = null;
static String PACKEGE = "com.example.isbnapp";
static String DB = "isbn.db";
static int VERSION = 1;
public MySQLiteOpenHelper(Context context) {
super(context, NAME, FACTORY, VERSION);
// TODO Auto-generated constructor stub
try {
boolean bResult = isCheckDB(context); // DB가 있는지?
Log.i("MiniApp", "DB Check="+bResult);
if(!bResult){ // DB가 없으면 복사
copyDB(context);
}else{
}
} catch (Exception e) {
}
}
// DB가 있나 체크하기
public boolean isCheckDB(Context mContext){
String filePath = "/data/data/" + PACKEGE + "/databases/" + DB;
File file = new File(filePath);
if (file.exists()) {
return true;
}
return false;
}
// DB를 복사하기
// assets의 /db/xxxx.db 파일을 설치된 프로그램의 내부 DB공간으로 복사하기
public void copyDB(Context mContext){
Log.d("MiniApp", "copyDB");
AssetManager manager = mContext.getAssets();
String folderPath = "/data/data/" + PACKEGE + "/databases";
String filePath = "/data/data/" + PACKEGE + "/databases/" +DB;
File folder = new File(folderPath);
File file = new File(filePath);
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
InputStream is = manager.open("db/" + DB);
BufferedInputStream bis = new BufferedInputStream(is);
if (folder.exists()) {
}else{
folder.mkdirs();
}
if (file.exists()) {
file.delete();
file.createNewFile();
}
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
int read = -1;
byte[] buffer = new byte[1024];
while ((read = bis.read(buffer, 0, 1024)) != -1) {
bos.write(buffer, 0, read);
}
bos.flush();
bos.close();
fos.close();
bis.close();
is.close();
} catch (IOException e) {
Log.e("ErrorMessage : ", e.getMessage());
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(SQLiteDatabase db) {
// String QUERY = "CREATE TABLE word (_id INTEGER PRIMARY KEY autoincrement, word_e TEXT , word_k TEXT)";
// db.execSQL(QUERY);
Log.e("ehsk", "eee");
// String QUERY1 = "INSERT INTO word (word_e, word_k ) VALUES(apple , 사과)";
// db.execSQL(QUERY1);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
String QUERY = "DROP TABLE IF EXISTS word";
db.execSQL(QUERY);
onCreate(db);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 362 | ||
| 7929 | 9년 전 | 257 | ||
| 7928 | 9년 전 | 365 | ||
| 7927 | 9년 전 | 293 | ||
| 7926 | 9년 전 | 641 | ||
| 7925 | 9년 전 | 307 | ||
| 7924 | 9년 전 | 278 | ||
| 7923 | 9년 전 | 319 | ||
| 7922 | 9년 전 | 337 | ||
| 7921 | 9년 전 | 371 | ||
| 7920 | 9년 전 | 293 | ||
| 7919 | 9년 전 | 308 | ||
| 7918 | 9년 전 | 473 | ||
| 7917 | 9년 전 | 311 | ||
| 7916 | 9년 전 | 378 | ||
| 7915 | 9년 전 | 360 | ||
| 7914 | 9년 전 | 378 | ||
| 7913 | 9년 전 | 498 | ||
| 7912 | 9년 전 | 372 | ||
| 7911 | 9년 전 | 327 | ||
| 7910 | 9년 전 | 358 | ||
| 7909 | 9년 전 | 466 | ||
| 7908 | 9년 전 | 365 | ||
| 7907 | 9년 전 | 315 | ||
| 7906 | 9년 전 | 329 | ||
| 7905 | 9년 전 | 326 | ||
| 7904 | 9년 전 | 292 | ||
| 7903 | 9년 전 | 287 | ||
| 7902 | 9년 전 | 508 | ||
| 7901 |
|
9년 전 | 713 | |
| 7900 | 9년 전 | 536 | ||
| 7899 | 9년 전 | 342 | ||
| 7898 | 9년 전 | 336 | ||
| 7897 | 9년 전 | 293 | ||
| 7896 | 9년 전 | 313 | ||
| 7895 | 9년 전 | 422 | ||
| 7894 | 9년 전 | 346 | ||
| 7893 | 9년 전 | 273 | ||
| 7892 | 9년 전 | 320 | ||
| 7891 | 9년 전 | 705 | ||
| 7890 | 9년 전 | 1167 | ||
| 7889 | 9년 전 | 729 | ||
| 7888 |
limsy1987
|
9년 전 | 522 | |
| 7887 | 9년 전 | 499 | ||
| 7886 | 9년 전 | 378 | ||
| 7885 | 9년 전 | 357 | ||
| 7884 | 9년 전 | 363 | ||
| 7883 | 9년 전 | 341 | ||
| 7882 | 9년 전 | 358 | ||
| 7881 | 9년 전 | 383 | ||
| 7880 | 9년 전 | 509 | ||
| 7879 | 9년 전 | 410 | ||
| 7878 | 9년 전 | 1149 | ||
| 7877 | 9년 전 | 703 | ||
| 7876 | 9년 전 | 430 | ||
| 7875 | 9년 전 | 505 | ||
| 7874 |
|
9년 전 | 774 | |
| 7873 | 9년 전 | 479 | ||
| 7872 | 9년 전 | 606 | ||
| 7871 | 9년 전 | 442 | ||
| 7870 | 9년 전 | 565 | ||
| 7869 | 9년 전 | 383 | ||
| 7868 | 9년 전 | 373 | ||
| 7867 | 9년 전 | 376 | ||
| 7866 | 9년 전 | 434 | ||
| 7865 | 9년 전 | 393 | ||
| 7864 | 9년 전 | 455 | ||
| 7863 | 9년 전 | 447 | ||
| 7862 | 9년 전 | 424 | ||
| 7861 | 9년 전 | 586 | ||
| 7860 | 9년 전 | 592 | ||
| 7859 | 9년 전 | 360 | ||
| 7858 | 9년 전 | 669 | ||
| 7857 | 9년 전 | 1017 | ||
| 7856 | 9년 전 | 479 | ||
| 7855 | 9년 전 | 696 | ||
| 7854 | 9년 전 | 694 | ||
| 7853 | 9년 전 | 524 | ||
| 7852 | 9년 전 | 468 | ||
| 7851 | 9년 전 | 443 | ||
| 7850 | 9년 전 | 537 | ||
| 7849 | 9년 전 | 312 | ||
| 7848 | 9년 전 | 356 | ||
| 7847 | 9년 전 | 583 | ||
| 7846 | 9년 전 | 401 | ||
| 7845 | 9년 전 | 365 | ||
| 7844 | 9년 전 | 363 | ||
| 7843 | 9년 전 | 367 | ||
| 7842 | 9년 전 | 364 | ||
| 7841 | 9년 전 | 351 | ||
| 7840 | 9년 전 | 356 | ||
| 7839 | 9년 전 | 391 | ||
| 7838 | 9년 전 | 477 | ||
| 7837 | 9년 전 | 316 | ||
| 7836 | 9년 전 | 356 | ||
| 7835 | 9년 전 | 436 | ||
| 7834 |
|
9년 전 | 1167 | |
| 7833 | 9년 전 | 373 | ||
| 7832 | 9년 전 | 362 | ||
| 7831 | 9년 전 | 497 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기