简体   繁体   中英

What's the best way to share images between users in a mobile application in android studio?

I'm creating a simple application where users can create wishlists, which is then stored in a mysql database. These wishlists contains an image of the item they want. What is the best way to go about sharing images between users? I couldn't find any good tutorials on how to use Android studio + mysql to share images, and most of the answers I see online are to "store only the path to the image in the database", but doesn't this mean you would have to store the images in the application itself, so the application would get larger and larger in size every time a user adds an image to a wishlist?

Would it be best to use an API (maybe Imgur?) to host the image, then retrieve the link, and store that link in the mysql database? Or maybe use a different kind of database, like firebase?

Please let me know if anyone here has done something similar in the past:) I'm open for any type of suggestion!

I figured I'd mention I code in Kotlin, but answers in Java are also much appreciated, as it's easy to convert:)

What is the best way to go about sharing images between users?

Kind of depends on what you mean by "sharing images between users". Like do you want one user to share an image from their wishlist to another user? Or do you mean that you want your app to re-use the same image between different users of the app so you don't waste space duplicating the image?

I couldn't find any good tutorials on how to use Android studio + mysql to share images, and most of the answers I see online are to "store only the path to the image in the database", but doesn't this mean you would have to store the images in the application itself, so the application would get larger and larger in size every time a user adds an image to a wishlist?

No. Photos are generally stored in shared, external directories, so then you only need the path / URI to that location in your application. Of course, then you have to handle the case that the image goes missing, moves, or gets deleted since you have no control over the file itself.

See the documentation for more:

Would it be best to use an API (maybe Imgur?) to host the image, then retrieve the link, and store that link in the mysql database? Or maybe use a different kind of database, like firebase?

"Best" would be subjective and a matter of opinion. It really depends on your app and what you're trying to achieve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM