파일을 FileInputStream으로 byte로 받아서 db에 blob형으로 넣으려고 합니다.
아래는 파일을 FileInputStream으로 byte로 받는 함수이구요
=================================================================
public byte[] invertBinary(String filename,String filepath) throws FileNotFoundException {
Log.e("filepath + filename",filepath + filename);
byte data[] = null;
try {
File file = new File(filepath + filename);
FileInputStream fis = new FileInputStream(file);
data = new byte[fis.available()];
while(fis.read(data)!=-1){;}
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
return data;
}
=================================================================
이렇게 뽑아진 데이터를 디비 테이블에 넣으려고 합니다.
아래는 뽑아진 데이터로 디비에 insert하는 함수입니다.
=================================================================
public Boolean insertDB(String id,byte[] bs) {
String NowDay = getCurrentDay();
String NowTime = getCurrentTime();
try{
db.execSQL("INSERT INTO " + DB_TABLE + " VALUES (" + id + ", '" + NowDay + "', '" + NowTime + "',"+bs+");");
db.close();
}
catch (Exception e) {
e.getStackTrace();
return false;
}
return true;
}
=================================================================
아래는 디비 테이블 형태입니다.
=================================================================
private static final String DATABASE_CREATE =
"CREATE TABLE " + DB_TABLE + " (" + ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + DAY + " TEXT, "
+ TIME + " TEXT, " + VALUE + " BLOB);";
=================================================================
디비까지 만들어진것은 확인하였는데요.
데이터가 위에처럼하면 안드러가지네요;;
도움 부탁드립니다 ^_^




보통 LOB형들은 그냥 쓰지 않구요...
statement를 이용해서 넣는게 보통인걸로 압니다. (PHP같은데서도 그렇게 쓰는걸로 알아요)
SQLiteStatement stmt = db.compileStatement(insQuery);
stmt.bindBlob(index, value);
이런 구문들이 있네요 insQuery의 경우는
insert into table (a,b,c) values(?,?,?)
이렇게 만들어서 쓰시면 됩니다. index가 0부터인지 1부터인지는 잘 모르겠네요... 그건 레퍼런스 보고 하세요.