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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6430 | 12년 전 | 985 | ||
| 6429 | 12년 전 | 9106 | ||
| 6428 | 12년 전 | 606 | ||
| 6427 |
제이티37
|
12년 전 | 1571 | |
| 6426 |
프로프리랜서
|
12년 전 | 1155 | |
| 6425 |
프로프리랜서
|
12년 전 | 1611 | |
| 6424 |
프로프리랜서
|
12년 전 | 1814 | |
| 6423 | 12년 전 | 1003 | ||
| 6422 |
퍼블리셔지노군
|
12년 전 | 1575 | |
| 6421 | 12년 전 | 2211 | ||
| 6420 |
|
12년 전 | 1334 | |
| 6419 |
|
12년 전 | 1287 | |
| 6418 | 12년 전 | 1186 | ||
| 6417 |
senseme
|
12년 전 | 7426 | |
| 6416 |
senseme
|
12년 전 | 1331 | |
| 6415 |
senseme
|
12년 전 | 1193 | |
| 6414 |
senseme
|
12년 전 | 1971 | |
| 6413 |
senseme
|
12년 전 | 976 | |
| 6412 |
senseme
|
12년 전 | 1493 | |
| 6411 |
senseme
|
12년 전 | 1106 | |
| 6410 |
senseme
|
12년 전 | 1049 | |
| 6409 |
PASKRAN
|
12년 전 | 2818 | |
| 6408 | 12년 전 | 10803 | ||
| 6407 | 12년 전 | 2991 | ||
| 6406 |
프로프리랜서
|
12년 전 | 2837 | |
| 6405 |
프로프리랜서
|
12년 전 | 1374 | |
| 6404 |
프로프리랜서
|
12년 전 | 2725 | |
| 6403 |
프로프리랜서
|
12년 전 | 821 | |
| 6402 |
프로프리랜서
|
12년 전 | 1736 | |
| 6401 |
프로프리랜서
|
12년 전 | 1141 | |
| 6400 |
프로프리랜서
|
12년 전 | 1470 | |
| 6399 |
프로프리랜서
|
12년 전 | 1182 | |
| 6398 |
프로프리랜서
|
12년 전 | 1496 | |
| 6397 |
프로프리랜서
|
12년 전 | 3606 | |
| 6396 | 12년 전 | 1874 | ||
| 6395 | 12년 전 | 921 | ||
| 6394 |
|
12년 전 | 5241 | |
| 6393 |
제이티37
|
12년 전 | 1206 | |
| 6392 |
songsinica
|
12년 전 | 1211 | |
| 6391 |
|
12년 전 | 3395 | |
| 6390 |
|
12년 전 | 1627 | |
| 6389 | 12년 전 | 4861 | ||
| 6388 |
스누피사랑
|
12년 전 | 5434 | |
| 6387 | 12년 전 | 1838 | ||
| 6386 | 12년 전 | 3063 | ||
| 6385 |
희망과열정
|
12년 전 | 929 | |
| 6384 | 12년 전 | 3295 | ||
| 6383 | 12년 전 | 10601 | ||
| 6382 |
|
12년 전 | 5791 | |
| 6381 |
SugarSkull
|
12년 전 | 1032 | |
| 6380 | 12년 전 | 782 | ||
| 6379 |
|
12년 전 | 1984 | |
| 6378 | 12년 전 | 1564 | ||
| 6377 | 12년 전 | 500 | ||
| 6376 |
후라보노보노
|
12년 전 | 1334 | |
| 6375 | 12년 전 | 2873 | ||
| 6374 | 12년 전 | 838 | ||
| 6373 | 12년 전 | 2368 | ||
| 6372 |
takumi22
|
12년 전 | 1241 | |
| 6371 |
개초보제이
|
12년 전 | 778 | |
| 6370 |
고급자가되고
|
12년 전 | 1463 | |
| 6369 | 12년 전 | 888 | ||
| 6368 | 12년 전 | 3187 | ||
| 6367 | 12년 전 | 1882 | ||
| 6366 | 12년 전 | 2886 | ||
| 6365 |
lilyosia
|
12년 전 | 1798 | |
| 6364 | 12년 전 | 1060 | ||
| 6363 | 12년 전 | 1593 | ||
| 6362 | 12년 전 | 2738 | ||
| 6361 | 12년 전 | 2562 | ||
| 6360 | 12년 전 | 1011 | ||
| 6359 | 12년 전 | 2105 | ||
| 6358 |
|
12년 전 | 1791 | |
| 6357 |
에헤라디야자진방아를돌려라
|
12년 전 | 786 | |
| 6356 | 12년 전 | 2093 | ||
| 6355 | 12년 전 | 3788 | ||
| 6354 | 12년 전 | 3102 | ||
| 6353 | 12년 전 | 1548 | ||
| 6352 | 12년 전 | 7772 | ||
| 6351 | 12년 전 | 2540 | ||
| 6350 | 12년 전 | 2800 | ||
| 6349 | 12년 전 | 1882 | ||
| 6348 | 12년 전 | 3549 | ||
| 6347 | 12년 전 | 1449 | ||
| 6346 | 12년 전 | 1194 | ||
| 6345 | 12년 전 | 1835 | ||
| 6344 | 12년 전 | 1416 | ||
| 6343 |
프로프리랜서
|
12년 전 | 2060 | |
| 6342 |
프로프리랜서
|
12년 전 | 1391 | |
| 6341 |
프로프리랜서
|
12년 전 | 1814 | |
| 6340 |
프로프리랜서
|
12년 전 | 1905 | |
| 6339 |
프로프리랜서
|
12년 전 | 1347 | |
| 6338 |
프로프리랜서
|
12년 전 | 1616 | |
| 6337 | 12년 전 | 5275 | ||
| 6336 |
프로프리랜서
|
12년 전 | 1634 | |
| 6335 |
프로프리랜서
|
12년 전 | 951 | |
| 6334 |
프로프리랜서
|
12년 전 | 1330 | |
| 6333 |
프로프리랜서
|
12년 전 | 2444 | |
| 6332 | 12년 전 | 1102 | ||
| 6331 |
돗단배123
|
12년 전 | 1422 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기