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);
}
}
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5830 | 13년 전 | 1190 | ||
| 5829 | 13년 전 | 5055 | ||
| 5828 | 13년 전 | 6439 | ||
| 5827 | 13년 전 | 1213 | ||
| 5826 |
|
13년 전 | 540 | |
| 5825 | 13년 전 | 900 | ||
| 5824 |
|
13년 전 | 1885 | |
| 5823 | 13년 전 | 5621 | ||
| 5822 |
jfascas
|
13년 전 | 1057 | |
| 5821 | 13년 전 | 1704 | ||
| 5820 | 13년 전 | 1316 | ||
| 5819 |
itlang
|
13년 전 | 513 | |
| 5818 | 13년 전 | 1309 | ||
| 5817 | 13년 전 | 785 | ||
| 5816 | 13년 전 | 625 | ||
| 5815 | 13년 전 | 6136 | ||
| 5814 | 13년 전 | 864 | ||
| 5813 |
악마의유혹
|
13년 전 | 463 | |
| 5812 | 13년 전 | 2810 | ||
| 5811 | 13년 전 | 1181 | ||
| 5810 | 13년 전 | 3534 | ||
| 5809 | 13년 전 | 1359 | ||
| 5808 | 13년 전 | 1065 | ||
| 5807 | 13년 전 | 576 | ||
| 5806 | 13년 전 | 562 | ||
| 5805 |
angrysol
|
13년 전 | 820 | |
| 5804 | 13년 전 | 1011 | ||
| 5803 | 13년 전 | 1741 | ||
| 5802 |
angrysol
|
13년 전 | 1067 | |
| 5801 |
후라보노보노
|
13년 전 | 2154 | |
| 5800 | 13년 전 | 1115 | ||
| 5799 |
|
13년 전 | 4198 | |
| 5798 |
|
13년 전 | 3365 | |
| 5797 |
|
13년 전 | 4940 | |
| 5796 | 13년 전 | 7549 | ||
| 5795 | 13년 전 | 2778 | ||
| 5794 | 13년 전 | 2231 | ||
| 5793 |
|
13년 전 | 663 | |
| 5792 | 13년 전 | 2974 | ||
| 5791 | 13년 전 | 848 | ||
| 5790 | 13년 전 | 4331 | ||
| 5789 |
|
13년 전 | 2479 | |
| 5788 |
|
13년 전 | 1854 | |
| 5787 |
오지랖선생
|
13년 전 | 1622 | |
| 5786 | 13년 전 | 5928 | ||
| 5785 | 13년 전 | 1768 | ||
| 5784 |
|
13년 전 | 1452 | |
| 5783 | 13년 전 | 1312 | ||
| 5782 |
|
13년 전 | 2823 | |
| 5781 | 13년 전 | 2857 | ||
| 5780 | 13년 전 | 1159 | ||
| 5779 |
|
13년 전 | 1358 | |
| 5778 |
오리진소프트
|
13년 전 | 4609 | |
| 5777 | 13년 전 | 684 | ||
| 5776 | 13년 전 | 1165 | ||
| 5775 | 13년 전 | 1472 | ||
| 5774 | 13년 전 | 1896 | ||
| 5773 |
|
13년 전 | 1922 | |
| 5772 | 13년 전 | 1687 | ||
| 5771 | 13년 전 | 4795 | ||
| 5770 | 13년 전 | 1130 | ||
| 5769 | 13년 전 | 6107 | ||
| 5768 |
|
13년 전 | 1579 | |
| 5767 | 13년 전 | 1687 | ||
| 5766 |
프로프리랜서
|
13년 전 | 1388 | |
| 5765 |
|
13년 전 | 1040 | |
| 5764 | 13년 전 | 1761 | ||
| 5763 |
|
13년 전 | 786 | |
| 5762 |
|
13년 전 | 2290 | |
| 5761 | 13년 전 | 619 | ||
| 5760 | 13년 전 | 625 | ||
| 5759 | 13년 전 | 3270 | ||
| 5758 | 13년 전 | 1087 | ||
| 5757 |
|
13년 전 | 744 | |
| 5756 | 13년 전 | 570 | ||
| 5755 | 13년 전 | 1064 | ||
| 5754 |
|
13년 전 | 2230 | |
| 5753 | 13년 전 | 679 | ||
| 5752 | 13년 전 | 1548 | ||
| 5751 | 13년 전 | 771 | ||
| 5750 | 13년 전 | 755 | ||
| 5749 | 13년 전 | 2579 | ||
| 5748 | 13년 전 | 1013 | ||
| 5747 | 13년 전 | 1220 | ||
| 5746 |
|
13년 전 | 655 | |
| 5745 | 13년 전 | 1660 | ||
| 5744 | 13년 전 | 690 | ||
| 5743 | 13년 전 | 834 | ||
| 5742 |
프로프리랜서
|
13년 전 | 580 | |
| 5741 | 13년 전 | 643 | ||
| 5740 | 13년 전 | 633 | ||
| 5739 | 13년 전 | 731 | ||
| 5738 | 13년 전 | 1927 | ||
| 5737 | 13년 전 | 992 | ||
| 5736 | 13년 전 | 1095 | ||
| 5735 | 13년 전 | 1996 | ||
| 5734 | 13년 전 | 1145 | ||
| 5733 | 13년 전 | 2789 | ||
| 5732 |
JOYCOM
|
13년 전 | 648 | |
| 5731 | 13년 전 | 3309 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기