Home > Mobile >  Android images are added to the database, reading and writing.
Android images are added to the database, reading and writing.

Time:09-27

Recent school decorate a task, involving database to store photos, and read out, according to

This database suddenly how do write picture, not to teach,
Hope to be able to explain in detail,

CodePudding user response:

Binary storage,

CodePudding user response:

 
FileInputStream fis=new FileInputStream (" D: \ \ liebao \ \ test \ \ '\ \ Auxi PNG ");
Byte [] buff=new byte [fis. Available ()];
Fis. Read (buff);
Blob b=??? ;//need through SQL instantiation here
Try {
B.s etBytes (0, buff);
} the catch (SQLException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}

Finally, still don't suggest such storage, if the image is too big, database performance will be affected

CodePudding user response:

Base64 is converted into a string

CodePudding user response:

So could you tell me with what method good

CodePudding user response:

The
reference 4 floor weixin_45682496 reply:
so could you tell me with what method good


Save database, I generally is to put the pictures into base64 string stored, take out the pictures of base64 string back when to go

CodePudding user response:

Best method is to store the picture links, so as not to worry about storage is too big, and can be controlled by Glide photo frame processing, such as a perfect combination! I think you want to so complicated,,,

CodePudding user response:

Can put a picture address or path, don't want to deposit the images to the database, can turn base64 stored in the form of a string,

CodePudding user response:

Three kinds of solution
1, turn base64 deposit to the local database
2, save the local then data inventory local file path
3, save the cloud, and then get a link to the local database
  • Related