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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 9년 전 | 378 | ||
| 7829 |
|
9년 전 | 554 | |
| 7828 | 9년 전 | 489 | ||
| 7827 | 9년 전 | 373 | ||
| 7826 | 9년 전 | 381 | ||
| 7825 | 9년 전 | 435 | ||
| 7824 | 9년 전 | 417 | ||
| 7823 | 9년 전 | 324 | ||
| 7822 | 9년 전 | 318 | ||
| 7821 | 9년 전 | 262 | ||
| 7820 | 9년 전 | 318 | ||
| 7819 |
|
9년 전 | 721 | |
| 7818 | 10년 전 | 335 | ||
| 7817 | 10년 전 | 454 | ||
| 7816 | 10년 전 | 357 | ||
| 7815 | 10년 전 | 562 | ||
| 7814 | 10년 전 | 386 | ||
| 7813 | 10년 전 | 327 | ||
| 7812 | 10년 전 | 345 | ||
| 7811 | 10년 전 | 362 | ||
| 7810 | 10년 전 | 494 | ||
| 7809 | 10년 전 | 436 | ||
| 7808 | 10년 전 | 300 | ||
| 7807 | 10년 전 | 361 | ||
| 7806 |
프로그래머7
|
10년 전 | 1307 | |
| 7805 | 10년 전 | 1219 | ||
| 7804 |
zahir1312
|
10년 전 | 744 | |
| 7803 |
|
10년 전 | 1345 | |
| 7802 | 10년 전 | 402 | ||
| 7801 | 10년 전 | 830 | ||
| 7800 | 10년 전 | 1049 | ||
| 7799 | 10년 전 | 506 | ||
| 7798 | 10년 전 | 452 | ||
| 7797 | 10년 전 | 452 | ||
| 7796 | 10년 전 | 304 | ||
| 7795 | 10년 전 | 455 | ||
| 7794 | 10년 전 | 478 | ||
| 7793 | 10년 전 | 998 | ||
| 7792 | 10년 전 | 408 | ||
| 7791 | 10년 전 | 489 | ||
| 7790 | 10년 전 | 454 | ||
| 7789 |
fbastore
|
10년 전 | 1403 | |
| 7788 | 10년 전 | 487 | ||
| 7787 | 10년 전 | 353 | ||
| 7786 | 10년 전 | 505 | ||
| 7785 | 10년 전 | 522 | ||
| 7784 | 10년 전 | 591 | ||
| 7783 | 10년 전 | 392 | ||
| 7782 | 10년 전 | 448 | ||
| 7781 | 10년 전 | 850 | ||
| 7780 | 10년 전 | 778 | ||
| 7779 | 10년 전 | 747 | ||
| 7778 | 10년 전 | 316 | ||
| 7777 | 10년 전 | 398 | ||
| 7776 | 10년 전 | 405 | ||
| 7775 | 10년 전 | 339 | ||
| 7774 | 10년 전 | 602 | ||
| 7773 | 10년 전 | 322 | ||
| 7772 | 10년 전 | 668 | ||
| 7771 | 10년 전 | 329 | ||
| 7770 | 10년 전 | 612 | ||
| 7769 | 10년 전 | 331 | ||
| 7768 | 10년 전 | 548 | ||
| 7767 | 10년 전 | 1116 | ||
| 7766 | 10년 전 | 444 | ||
| 7765 | 10년 전 | 477 | ||
| 7764 |
잘살아보자
|
10년 전 | 326 | |
| 7763 |
|
10년 전 | 1400 | |
| 7762 |
Tosea
|
10년 전 | 1018 | |
| 7761 | 10년 전 | 614 | ||
| 7760 |
잘살아보자
|
10년 전 | 604 | |
| 7759 |
잘살아보자
|
10년 전 | 418 | |
| 7758 |
잘살아보자
|
10년 전 | 532 | |
| 7757 | 10년 전 | 1181 | ||
| 7756 |
ITBANK
|
10년 전 | 1217 | |
| 7755 | 10년 전 | 1895 | ||
| 7754 | 10년 전 | 998 | ||
| 7753 | 10년 전 | 843 | ||
| 7752 | 10년 전 | 1349 | ||
| 7751 |
잘살아보자
|
10년 전 | 472 | |
| 7750 |
잘살아보자
|
10년 전 | 441 | |
| 7749 |
잘살아보자
|
10년 전 | 439 | |
| 7748 |
잘살아보자
|
10년 전 | 421 | |
| 7747 |
잘살아보자
|
10년 전 | 509 | |
| 7746 |
잘살아보자
|
10년 전 | 633 | |
| 7745 |
잘살아보자
|
10년 전 | 876 | |
| 7744 |
잘살아보자
|
10년 전 | 387 | |
| 7743 | 10년 전 | 912 | ||
| 7742 |
starbros
|
10년 전 | 786 | |
| 7741 |
잘살아보자
|
10년 전 | 604 | |
| 7740 |
잘살아보자
|
10년 전 | 479 | |
| 7739 |
잘살아보자
|
10년 전 | 434 | |
| 7738 |
잘살아보자
|
10년 전 | 488 | |
| 7737 |
잘살아보자
|
10년 전 | 448 | |
| 7736 |
잘살아보자
|
10년 전 | 466 | |
| 7735 |
잘살아보자
|
10년 전 | 801 | |
| 7734 |
잘살아보자
|
10년 전 | 394 | |
| 7733 |
잘살아보자
|
10년 전 | 494 | |
| 7732 |
잘살아보자
|
10년 전 | 650 | |
| 7731 |
잘살아보자
|
10년 전 | 579 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기