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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 414 | ||
| 8029 | 9년 전 | 336 | ||
| 8028 | 9년 전 | 295 | ||
| 8027 | 9년 전 | 308 | ||
| 8026 | 9년 전 | 380 | ||
| 8025 | 9년 전 | 410 | ||
| 8024 | 9년 전 | 397 | ||
| 8023 | 9년 전 | 424 | ||
| 8022 | 9년 전 | 339 | ||
| 8021 | 9년 전 | 362 | ||
| 8020 | 9년 전 | 361 | ||
| 8019 | 9년 전 | 376 | ||
| 8018 | 9년 전 | 478 | ||
| 8017 | 9년 전 | 559 | ||
| 8016 | 9년 전 | 382 | ||
| 8015 | 9년 전 | 417 | ||
| 8014 | 9년 전 | 347 | ||
| 8013 | 9년 전 | 269 | ||
| 8012 | 9년 전 | 270 | ||
| 8011 | 9년 전 | 478 | ||
| 8010 | 9년 전 | 333 | ||
| 8009 | 9년 전 | 349 | ||
| 8008 | 9년 전 | 317 | ||
| 8007 | 9년 전 | 465 | ||
| 8006 | 9년 전 | 502 | ||
| 8005 |
|
9년 전 | 995 | |
| 8004 | 9년 전 | 385 | ||
| 8003 | 9년 전 | 454 | ||
| 8002 | 9년 전 | 348 | ||
| 8001 |
|
9년 전 | 692 | |
| 8000 | 9년 전 | 457 | ||
| 7999 | 9년 전 | 408 | ||
| 7998 | 9년 전 | 466 | ||
| 7997 | 9년 전 | 336 | ||
| 7996 | 9년 전 | 565 | ||
| 7995 | 9년 전 | 512 | ||
| 7994 | 9년 전 | 401 | ||
| 7993 | 9년 전 | 470 | ||
| 7992 | 9년 전 | 542 | ||
| 7991 | 9년 전 | 289 | ||
| 7990 | 9년 전 | 325 | ||
| 7989 | 9년 전 | 329 | ||
| 7988 | 9년 전 | 758 | ||
| 7987 | 9년 전 | 461 | ||
| 7986 | 9년 전 | 463 | ||
| 7985 | 9년 전 | 542 | ||
| 7984 | 9년 전 | 461 | ||
| 7983 | 9년 전 | 698 | ||
| 7982 | 9년 전 | 558 | ||
| 7981 | 9년 전 | 516 | ||
| 7980 | 9년 전 | 537 | ||
| 7979 | 9년 전 | 528 | ||
| 7978 | 9년 전 | 491 | ||
| 7977 | 9년 전 | 432 | ||
| 7976 | 9년 전 | 891 | ||
| 7975 | 9년 전 | 405 | ||
| 7974 | 9년 전 | 450 | ||
| 7973 | 9년 전 | 631 | ||
| 7972 | 9년 전 | 423 | ||
| 7971 | 9년 전 | 499 | ||
| 7970 | 9년 전 | 341 | ||
| 7969 | 9년 전 | 580 | ||
| 7968 | 9년 전 | 427 | ||
| 7967 | 9년 전 | 411 | ||
| 7966 | 9년 전 | 416 | ||
| 7965 |
|
9년 전 | 1045 | |
| 7964 | 9년 전 | 434 | ||
| 7963 | 9년 전 | 443 | ||
| 7962 | 9년 전 | 444 | ||
| 7961 |
전갈자리남자
|
9년 전 | 535 | |
| 7960 | 9년 전 | 1002 | ||
| 7959 | 9년 전 | 585 | ||
| 7958 | 9년 전 | 436 | ||
| 7957 | 9년 전 | 393 | ||
| 7956 | 9년 전 | 390 | ||
| 7955 | 9년 전 | 493 | ||
| 7954 | 9년 전 | 429 | ||
| 7953 | 9년 전 | 476 | ||
| 7952 | 9년 전 | 398 | ||
| 7951 | 9년 전 | 529 | ||
| 7950 | 9년 전 | 426 | ||
| 7949 | 9년 전 | 418 | ||
| 7948 | 9년 전 | 355 | ||
| 7947 | 9년 전 | 973 | ||
| 7946 | 9년 전 | 488 | ||
| 7945 | 9년 전 | 434 | ||
| 7944 | 9년 전 | 492 | ||
| 7943 | 9년 전 | 423 | ||
| 7942 | 9년 전 | 437 | ||
| 7941 | 9년 전 | 428 | ||
| 7940 | 9년 전 | 928 | ||
| 7939 | 9년 전 | 419 | ||
| 7938 | 9년 전 | 436 | ||
| 7937 | 9년 전 | 325 | ||
| 7936 | 9년 전 | 908 | ||
| 7935 | 9년 전 | 510 | ||
| 7934 | 9년 전 | 490 | ||
| 7933 | 9년 전 | 615 | ||
| 7932 | 9년 전 | 554 | ||
| 7931 | 9년 전 | 614 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기