Android将imageview转换为sqlite

时间:2015-12-08 18:25:21

标签: android sqlite

AddNote.java ---在Onclick(View v){}

            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);

AddNote.java ---在onSelected(意图数据){}

            bm = BitmapFactory.decodeFile(selectedImagePath, options);
            ivImage.setImageBitmap(bm);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bm.compress(CompressFormat.JPEG, 100, baos);
            byte[] imageData = baos.toByteArray();

DBhelperNote.java ---创建数据库

            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 "+
            " );";

SQLControler.java --- in insertNote(String name,String description,String photo){}

            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);
            }

如何将我的imageData插入已创建的sqlite数据库?

0 个答案:

没有答案