Skip to content Skip to sidebar Skip to footer

How Do I Allow Users To Upload Images To My App, And Use Them?

I'm building an app which will allow the user to upload their own icons for use within the app (these will be small .png or .gif files). I want to include a default set of icons,

Solution 1:

Read about internal and external storage in Android here: https://developer.android.com/guide/topics/data/data-storage.html

The only difference is that in internal storage the images/data is not accessible by users if they say, plug their phone into their computer and try to view the files. In external storage all items are public.

For some sample code on how to have users save images in your app take a look at this SO post: Saving and Reading Bitmaps/Images from Internal memory in Android

You can then just store the filenames of the icons in shared preferences (if you don't anticipate that many icons and your model is simple) or SQLite if your model is more complex. Since you sound like a beginner I would recommend start with shared preferences?

As for the default icons you store with your app, yes you can put them in the drawables folder (with different sizes for different screens if you are doing that thing), but since you already know the names of those drawable resources can't you just display whatever one you want with Java when you need to? I am not sure what the reason would be to store those in a database but then again I have no idea what you are building.

Hope this helps.

Post a Comment for "How Do I Allow Users To Upload Images To My App, And Use Them?"