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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7430 |
|
11년 전 | 4947 | |
| 7429 | 11년 전 | 1780 | ||
| 7428 |
멋진남자임
|
11년 전 | 1173 | |
| 7427 |
sdflksdj2
|
11년 전 | 831 | |
| 7426 | 11년 전 | 1366 | ||
| 7425 | 11년 전 | 1393 | ||
| 7424 | 11년 전 | 1054 | ||
| 7423 |
SeungYeon
|
11년 전 | 565 | |
| 7422 | 11년 전 | 811 | ||
| 7421 |
sdflksdj2
|
11년 전 | 691 | |
| 7420 | 11년 전 | 973 | ||
| 7419 |
|
11년 전 | 1405 | |
| 7418 |
멋진남자임
|
11년 전 | 1441 | |
| 7417 | 11년 전 | 608 | ||
| 7416 |
senseme
|
11년 전 | 1233 | |
| 7415 | 11년 전 | 963 | ||
| 7414 | 11년 전 | 715 | ||
| 7413 | 11년 전 | 4851 | ||
| 7412 | 11년 전 | 4407 | ||
| 7411 |
holla
|
11년 전 | 898 | |
| 7410 | 11년 전 | 4254 | ||
| 7409 | 11년 전 | 3929 | ||
| 7408 | 11년 전 | 4273 | ||
| 7407 | 11년 전 | 5090 | ||
| 7406 | 11년 전 | 4737 | ||
| 7405 | 11년 전 | 4303 | ||
| 7404 | 11년 전 | 765 | ||
| 7403 | 11년 전 | 5685 | ||
| 7402 | 11년 전 | 1521 | ||
| 7401 |
|
11년 전 | 979 | |
| 7400 | 11년 전 | 2975 | ||
| 7399 |
멋진남자임
|
11년 전 | 920 | |
| 7398 |
파랑새1597
|
11년 전 | 2708 | |
| 7397 | 11년 전 | 2277 | ||
| 7396 |
basketball
|
11년 전 | 1377 | |
| 7395 | 11년 전 | 1615 | ||
| 7394 | 11년 전 | 934 | ||
| 7393 | 11년 전 | 2075 | ||
| 7392 | 11년 전 | 852 | ||
| 7391 |
잘살아보자
|
11년 전 | 5365 | |
| 7390 |
잘살아보자
|
11년 전 | 2230 | |
| 7389 |
잘살아보자
|
11년 전 | 3323 | |
| 7388 |
파랑새1597
|
11년 전 | 932 | |
| 7387 | 11년 전 | 1108 | ||
| 7386 |
프리랜서퍼블리셔
|
11년 전 | 973 | |
| 7385 | 11년 전 | 1572 | ||
| 7384 |
울라라라우
|
11년 전 | 893 | |
| 7383 | 11년 전 | 1559 | ||
| 7382 |
잘살아보자
|
11년 전 | 4230 | |
| 7381 |
잘살아보자
|
11년 전 | 2000 | |
| 7380 |
잘살아보자
|
11년 전 | 1944 | |
| 7379 |
잘살아보자
|
11년 전 | 5911 | |
| 7378 |
senseme
|
11년 전 | 1902 | |
| 7377 |
잘살아보자
|
11년 전 | 2751 | |
| 7376 | 11년 전 | 2420 | ||
| 7375 |
잘살아보자
|
11년 전 | 1053 | |
| 7374 |
잘살아보자
|
11년 전 | 3166 | |
| 7373 |
잘살아보자
|
11년 전 | 2483 | |
| 7372 |
잘살아보자
|
11년 전 | 5834 | |
| 7371 |
잘살아보자
|
11년 전 | 3470 | |
| 7370 |
잘살아보자
|
11년 전 | 1917 | |
| 7369 |
잘살아보자
|
11년 전 | 2175 | |
| 7368 |
ksdhtm56
|
11년 전 | 575 | |
| 7367 | 11년 전 | 1438 | ||
| 7366 | 11년 전 | 936 | ||
| 7365 | 11년 전 | 3548 | ||
| 7364 |
잘살아보자
|
11년 전 | 1400 | |
| 7363 |
잘살아보자
|
11년 전 | 1372 | |
| 7362 |
잘살아보자
|
11년 전 | 1512 | |
| 7361 | 11년 전 | 3597 | ||
| 7360 | 11년 전 | 3564 | ||
| 7359 | 11년 전 | 3382 | ||
| 7358 |
멋진남자임
|
11년 전 | 1031 | |
| 7357 | 11년 전 | 3417 | ||
| 7356 | 11년 전 | 2604 | ||
| 7355 | 11년 전 | 3198 | ||
| 7354 |
파랑새1597
|
11년 전 | 652 | |
| 7353 |
잘살아보자
|
11년 전 | 2430 | |
| 7352 |
잘살아보자
|
11년 전 | 2421 | |
| 7351 |
잘살아보자
|
11년 전 | 2483 | |
| 7350 |
잘살아보자
|
11년 전 | 1478 | |
| 7349 |
잘살아보자
|
11년 전 | 1971 | |
| 7348 |
잘살아보자
|
11년 전 | 1288 | |
| 7347 |
잘살아보자
|
11년 전 | 1084 | |
| 7346 |
멋진남자임
|
11년 전 | 1652 | |
| 7345 | 11년 전 | 995 | ||
| 7344 | 11년 전 | 3878 | ||
| 7343 | 11년 전 | 3661 | ||
| 7342 | 11년 전 | 1288 | ||
| 7341 | 11년 전 | 2526 | ||
| 7340 |
|
11년 전 | 941 | |
| 7339 | 11년 전 | 1740 | ||
| 7338 | 11년 전 | 3351 | ||
| 7337 | 11년 전 | 3666 | ||
| 7336 | 11년 전 | 4605 | ||
| 7335 | 11년 전 | 980 | ||
| 7334 | 11년 전 | 1538 | ||
| 7333 | 11년 전 | 2942 | ||
| 7332 |
|
11년 전 | 1114 | |
| 7331 |
KeePin뽁이
|
11년 전 | 1106 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기