Gallery app save image

i’m working on an app that is bassically a gallery where the user pick an image from library and are able to display it in another page, but when i exit the app and enter again, the imagem picked before desapears. what can i do to save this image? can you show me the steps?

some more insight on how the app works, would definitely be helpful, but from what i understand, the thing missing is that you need to assign that image in a variable and even save the file path so you are able to access it any time in the future, because now when you close the app and you reopen it the app doesnt know what image you chose before.

this is the logic when i click the button to pick the image

this is the logic in the page where the image appears

i’m stuck here. can you give me a light?

yeah, so as i imagined, after picking the image, you need to store it somehow, so the app knows what images you have chosen in the past.
one way is to store the local file path, you can get that from the output of the pick image logic, or an other way, would be to store the image in the locale storage (you can see how to do that in the forum) but this way, you store an image that is already stored. the advantage, is that if you store in in the device storage, even if the image is deleted from the phone gallery, your app will have the image saved.

thank you, but i still dont know what to do, i’m going craaaaazy! do you think you can show me the steps with images or a video??

@Adam_Wike hey, adam! saw you have some good tutorials on on-device storage, can you help me with this?

Hey @monicamonteiro.moura !

I believe I have some time tonight where I can show you how to do this.

Just to make sure I’m doing the correct thing…

  1. You want the user to pick an image from their photo library
  2. Display the image on a new page
  3. When the user opens the app again it should open to the page with the previously selected image

EDIT: Also, does the user need to be able to select multiple images or just one?

the idea of the application is to work as a “shortcut” to find previously selected files.

1 - home page: button > if no file has yet been selected, it directs you to the library, if you have already selected a file, you go directly to the page containing the selected files.

2 - on the page containing the selected files, when clicking on a file, open it in its original size and, if possible, enable the zoom function.

3 - all selected files must be saved in the app, so when I exit the app and enter again, when I click on the syringe, I will have access to the files I selected earlier.

I’d like to be able to select image and PDF files, but if it’s too complicated, selecting only images works.

on the syringe button, you can add only the first file, since, after selecting the first file, when clicked again, it already directs the user to the files preview page. if you want to add more files, this function will be assigned to another button on another page.

It is possible to notice that when I select a pdf, I can see it, but when I press the syringe, the file is white and when I click on the file, nothing appears.

I’m not sure I’ll finish up the tutorial tonight, but I’ll try to get it done in the morning some time. So far I’ve figured out how to save an image (I’m guessing it will work the same for a PDF) to the app’s Document directory and then I create an On device storage record to save where the document is located, the type, etc. Sooooo I think that what you’re wanting to do should be possible. Look for a video from me sometime tomorrow morning.

1 Like

thank you so much for this, really. i’m way too calmer after knowing you are going to help me ((((((: looking forward for the tutorial :pray:


Does this look like the functionality you want? It’s not pretty but I think it’s close to what you were asking for. I’ll do my best to explain how I did it in a youtube video soon. Busy weekend haha :slight_smile:

EDIT: Ignore the podcast playing in the background haha, sorry!

1 Like

exactly!!! except that the button to add image is on one page and the photos go to another page, but the main functionality of the app is being fulfilled perfectly: select image and pdf

thank you! looking forward to the tutorial (:

Should be available shortly. Thanks!! Let me know if I missed anything or you need any additional help.

1 Like

i’m not being able to visualize pdf in the web view

I believe that has to do with this bug: Android: Open Local File | Voters | AppGyver

I have the same issue in an app I’m working on. I work around it by using the PDF viewer on android and the web view on iOS. I’ll try and dive into a better way to overcome that issue and let you know what I find out. My issue with the PDF viewer is that it doesn’t have a back button and you have to swipe to go back.

how does the logic work with the pdf preview? i think, in my case, would work just fine. also, there is a possibility to display the imagem in the web view? because with this we are able to zoom the image

@monicamonteiro.moura Here is what I do to work around the PDF issue on Android. In your case, you wouldn’t be able to ‘preview’ the PDF anymore on the main page since the web view doesn’t work for both operating systems. You could show some kind of generic PDF image or something like that.

When the user clicks the PDF though it would open to the webview on iOS or the Preview PDF view on Android. When the user exits the PDF viewer I have it automatically take them back to the page they were on. Let me know if you need more details on this process and I’ll try to make a video or something. Thanks!

1 Like