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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6130 |
gender
|
12년 전 | 1096 | |
| 6129 | 12년 전 | 1322 | ||
| 6128 |
|
12년 전 | 3463 | |
| 6127 | 12년 전 | 696 | ||
| 6126 |
|
12년 전 | 2208 | |
| 6125 |
|
12년 전 | 4887 | |
| 6124 | 12년 전 | 661 | ||
| 6123 | 12년 전 | 3844 | ||
| 6122 | 12년 전 | 1018 | ||
| 6121 | 12년 전 | 3753 | ||
| 6120 | 12년 전 | 909 | ||
| 6119 | 12년 전 | 1770 | ||
| 6118 | 12년 전 | 931 | ||
| 6117 | 12년 전 | 2150 | ||
| 6116 | 12년 전 | 7943 | ||
| 6115 | 12년 전 | 1920 | ||
| 6114 |
|
12년 전 | 1708 | |
| 6113 | 12년 전 | 1526 | ||
| 6112 | 12년 전 | 595 | ||
| 6111 | 12년 전 | 2111 | ||
| 6110 | 12년 전 | 1851 | ||
| 6109 | 12년 전 | 642 | ||
| 6108 | 12년 전 | 1200 | ||
| 6107 | 12년 전 | 624 | ||
| 6106 | 12년 전 | 906 | ||
| 6105 | 12년 전 | 1193 | ||
| 6104 | 12년 전 | 3596 | ||
| 6103 | 12년 전 | 2124 | ||
| 6102 | 12년 전 | 2316 | ||
| 6101 | 12년 전 | 3677 | ||
| 6100 | 12년 전 | 3484 | ||
| 6099 | 12년 전 | 3155 | ||
| 6098 | 12년 전 | 4026 | ||
| 6097 | 12년 전 | 1017 | ||
| 6096 | 12년 전 | 5985 | ||
| 6095 | 12년 전 | 1370 | ||
| 6094 | 12년 전 | 1225 | ||
| 6093 | 12년 전 | 3408 | ||
| 6092 | 12년 전 | 3053 | ||
| 6091 | 12년 전 | 5195 | ||
| 6090 | 12년 전 | 2705 | ||
| 6089 | 12년 전 | 3327 | ||
| 6088 | 12년 전 | 1016 | ||
| 6087 | 12년 전 | 848 | ||
| 6086 | 12년 전 | 2019 | ||
| 6085 |
|
12년 전 | 807 | |
| 6084 |
웹디자인되고파
|
12년 전 | 2219 | |
| 6083 | 12년 전 | 1508 | ||
| 6082 | 12년 전 | 1111 | ||
| 6081 | 12년 전 | 2101 | ||
| 6080 |
Stiven
|
12년 전 | 2312 | |
| 6079 |
프로프리랜서
|
12년 전 | 1323 | |
| 6078 |
프로프리랜서
|
12년 전 | 787 | |
| 6077 |
프로프리랜서
|
12년 전 | 1345 | |
| 6076 |
프로프리랜서
|
12년 전 | 832 | |
| 6075 |
프로프리랜서
|
12년 전 | 1224 | |
| 6074 | 12년 전 | 3855 | ||
| 6073 | 12년 전 | 3949 | ||
| 6072 | 12년 전 | 1378 | ||
| 6071 | 12년 전 | 6992 | ||
| 6070 | 12년 전 | 7574 | ||
| 6069 | 12년 전 | 2320 | ||
| 6068 | 12년 전 | 3869 | ||
| 6067 |
smwkd
|
12년 전 | 633 | |
| 6066 | 12년 전 | 3658 | ||
| 6065 | 12년 전 | 3486 | ||
| 6064 | 12년 전 | 2720 | ||
| 6063 | 12년 전 | 2841 | ||
| 6062 | 12년 전 | 2372 | ||
| 6061 | 12년 전 | 2279 | ||
| 6060 | 12년 전 | 5185 | ||
| 6059 | 12년 전 | 2815 | ||
| 6058 | 12년 전 | 3137 | ||
| 6057 | 12년 전 | 2262 | ||
| 6056 | 12년 전 | 6842 | ||
| 6055 | 12년 전 | 2581 | ||
| 6054 | 12년 전 | 3436 | ||
| 6053 | 12년 전 | 2328 | ||
| 6052 | 12년 전 | 4822 | ||
| 6051 | 12년 전 | 3713 | ||
| 6050 | 12년 전 | 2555 | ||
| 6049 | 12년 전 | 2246 | ||
| 6048 |
|
12년 전 | 1300 | |
| 6047 | 12년 전 | 3441 | ||
| 6046 | 12년 전 | 4096 | ||
| 6045 | 12년 전 | 3456 | ||
| 6044 | 12년 전 | 5332 | ||
| 6043 | 12년 전 | 1652 | ||
| 6042 | 12년 전 | 1282 | ||
| 6041 | 12년 전 | 5165 | ||
| 6040 | 12년 전 | 940 | ||
| 6039 | 12년 전 | 3413 | ||
| 6038 | 12년 전 | 3414 | ||
| 6037 | 12년 전 | 2994 | ||
| 6036 | 12년 전 | 3342 | ||
| 6035 | 12년 전 | 2867 | ||
| 6034 | 12년 전 | 2846 | ||
| 6033 | 12년 전 | 2868 | ||
| 6032 | 12년 전 | 2854 | ||
| 6031 | 12년 전 | 2881 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기