Pre-populate the internal storage in android

76 Views Asked by At

I'm making a quiz app that has the same screen for all the questions. I want to store all the questions in a ROOM database and then load them one by one as the user progresses with levels. The problem is the questions can be a String but sometimes can be an image (like who is in the picture?) and from my research I learned that using typeConverters to store image in ROOM is bad instead I should store them in the internal storage and then store the path of the image in ROOM. Because it is a quiz app I have to prepopulate the ROOM DB so the app comes with all the questions ready which means the images should be pre-stored in internal storage and I can't seem to find a way to do that. Is there any way i can do it? If not then what other way I can acheive this with? keep in mind that I plan to have an option in the future to load new questions from an API if the user want to!

1

There are 1 best solutions below

0
Tenfour04 On

If the answers come with the app, they should be prepackaged resources or assets, not files in internal storage. You can't prepackage into internal storage--that doesn't make sense because internal storage is part of the end-user's device. Read about how to use resources and assets here in the documentation.

Your table can have a column to indicate the image location (internal files you have downloaded or pre-packaged resources/assets) and the app can use that info to determine how to load the image.