Onclick()
String name = et_Notename.getText().toString();
String description = et_Notedescription.getText().toString();
dbconnection.insertNote(name, description);
Intent main = new Intent(AddNote.this, NoteActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(main);
image
bm = BitmapFactory.decodeFile(selectedImagePath, options);
ivImage.setImageBitmap(bm);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 100, baos);
byte[] imageData = baos.toByteArray();
CreateDatabase
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NOTE + " (" +
NOTE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
NOTE_NAME + " text not null, " +
NOTE_DESCRIPTION + " text not null, "+
NOTE_PHOTO + " blob not null "+
" );";
InsertData
public void insertNote(String name,String description,String photo) {
ContentValues cv = new ContentValues();
cv.put(DBhelperNote.NOTE_NAME, name);
cv.put(DBhelperNote.NOTE_DESCRIPTION, description);
cv.put(DBhelperNote.NOTE_PHOTO, photo );
database.insert(DBhelperNote.TABLE_NOTE, null, cv);
}
How do i insert my imageData to sqlite database that i already created ?
Aucun commentaire:
Enregistrer un commentaire