-6

I am making a note taker android app using android studio for my school project. What it can currently do is save, view, edit & delete text notes. And i used sqlite.

But I need one more feature to add, which is saving photos as notes. The user can use the camera or phone gallery to save images, then saves it for viewing or to delete it later.

Can you guys help me out?

  • Possible duplicate of [How to store image in SQLite database](https://stackoverflow.com/questions/9357668/how-to-store-image-in-sqlite-database) – GianhTran Jun 22 '18 at 06:43

2 Answers2

1

As per my understanding .

Best way is to store the Image in SDCard or Internal app storage and save the Path in SQLite DB.

SRB Bans
  • 3,096
  • 1
  • 10
  • 21
0

You can try to convert the image's bytes to string

 encodedfile = new String(Base64.encodeBase64(bytes), "UTF-8");

and then save it to a text field.

You can get the image's bytes by using this code:

public byte[] extractBytes (String ImageName) throws IOException {
 // open image
 File imgPath = new File(ImageName);
 BufferedImage bufferedImage = ImageIO.read(imgPath);

 // get DataBufferBytes from Raster
 WritableRaster raster = bufferedImage .getRaster();
 DataBufferByte data   = (DataBufferByte) raster.getDataBuffer();

 return ( data.getData() );
}
Painful
  • 137
  • 1
  • 11