Problem with Saving Photos in MIT App Inventor – File Naming and Numbering
Hi, I am creating an app in MIT App Inventor for taking photos of parts, but I am having trouble saving the images.
My app works as follows:
I assign a name to the photo file.
Subsequent photos have the same initial name, but the suffix changes (_1.jpg, _2.jpg, _3.jpg, etc.).
The photos are saved on the phone's storage.
When I press a button, I start taking photos with a new name, and the numbering starts over.
The issue is that I am stuck on the saving process, and it is not working as expected. Could someone help me solve this problem? The app is essential for my work.
Thank you in advance for any guidance. foto.aia (2.6 KB)
In addition to the permissions required to access the storage and DefaultScope settings in File1, if you want it to work you will need to fill the path of the global variable 'photo_name'... because if this socket is empty it will not be possible to save the images.
Thank you for your reply. Could you please check my attached file in your free time? I'm an amateur and I wrote this program from various programs on YouTube.
You should use the tinydb to store the last number used each time you take a photo, then call this back when you restart the app, so that you can add 1 for the next photo.
Your project has already been checked ... both the answer and the images that illustrate it are proof of this ... But the speed at which you responded to my comment, indicates that neither read my answer nor the indicated link. Please read carefully the information given to you.
Thank you for your help and explanations. I have read your response and checked the provided information, but unfortunately, I am unable to fix the issue myself. I am an amateur and do not have enough experience to implement the required changes correctly.
Would someone be able to modify my project and fix the problem for me? I would really appreciate the help.
OK, in companion app (2.74u) on my device (Pixel 8a Android 15) AppInventor by default saves camera images to <ASD>/Pictures, so I simply rename that image to your image/counter name. (If this is not the same on your device then let me know.)
I use the tinydb to save the last counter number, and load this when the app restarts.
I’m really grateful for your help! The program is working and successfully saving the images, which makes me very happy. There’s just one issue: when I enter a name like "AAA," the images are saved as "AAA_1," "AAA_2," etc. However, if I then enter "BBB," the images are saved as "BBB_3" instead of starting from "BBB_1." But I think I can handle it from here.
I did it just like in the blocks, but it only saves the image with _1 and doesn’t move to the next number when changing the name. I think I’m doing something wrong after all.
However, I still can't figure it out. I tried making changes, but the counter still doesn't reset and doesn't start from 1 after renaming. Maybe it's because Tiny saves the counter in the phone's memory?