I have implemented image in EditEtxt. Its working fine. I want to save the whole editText entities(Text & image) in sql lite database. When i save it to sql only text are showing not images. I also tried with Html.toHtml
and Html.fromHtml
. Its also not working.
This bunch of code to add image in editText:
Uri imageUri= data.getData();
InputStream inputStream= getContentResolver().openInputStream(imageUri);
Bitmap bitmap= BitmapFactory.decodeStream(inputStream);
final Drawable drawable = new BitmapDrawable(getResources(), bitmap);
drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
final ImageSpan imageSpan = new ImageSpan(drawable,ImageSpan.ALIGN_BOTTOM);
SpannableStringBuilder span = new SpannableStringBuilder(editText.getText()+".\n");
span.setSpan(imageSpan, 0, (".\n").length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
editText.append(span, 0, (".\n").length());
To save in databse
String textWithImage= Html.toHtml(editText.getText());
Note note = new Note(textWithImage);
Databse databse= new Databse(this);
databse.insertInDB(note);
Fetch data from database
databse= new Databse(this);
note= databse.getSingleNote(noteId);
String text= note.getNoteText();
editText.setText(Html.fromHtml(text));
Please help someone to do this task. Thank you.