Strange problem when trying to reload images in android - android

So, the thing is that i've downloaded a couple of photos and stored them in the data/data/project/username directory on the phone and I want to display them (without having to download them again first) every time the user with username is using my application.
So've created a linkedlist with the paths on the phone where these photos are stored and every time a new photo is downloaded I add it to this linked list. Every time the activity is created/stopped i deserialize/serilize the list containning these links.
The serilialization part seems to be working ok, since I checked and the deserialized list seems to contain proper links to the the photos on the phone, but nonetheless when I start this activity nothing appears on the screen (before that I was downloading the photos every time the user logs in and they were displayed properly and everything was fine) and there's no error bumping in logcat or whatsoever. I first thought I had some typo when adding the photo urls to the list, but i checked and everything seems fine. Any ideas? (think)

Flickr photos have unique IDs. When you save the photos on the internal storage of the device, use their ID's for names (for example 123456111.jpg). When the user reconnects to Flicker, just check each image in his gallery if it is already downloaded.
It is good to use getCacheDir() for your cache directory, because it is automatically managed by Android.

Related

Can we automatically delete images on a device with Flutter?

My Flutter app will be used to capture image then save to device. I want to remove all images in my device at a preset time. Is there a way to do that?
I think it not because if an app can delete all the images in device so it will not safe to use that app but I still hope it have because it needs for my app.
Things are changing with the recent releases of Android. Access to file system is not going to be same. but you are going to save the captured image in a folder where you have write access, there you can delete all the pictures without a problem

How to get to know that image has been deleted from sdcard

I have an application which downloads the image and saves in the sdcard of the device and meanwhile it saves the name of downloaded image in the database along with their path (this path is a physical path on device)
Why I am doing this? It has only one reason and that is not to download images again and again from the server. But as I am saving them in the sdcard then they are showing in the Gallery. So there is chance that user can delete some of the images or may be all of them. (Due to some reasons I am not saving them in app folder)
So what I want
I want couple of things that can be simplify as following
I want to see that if any of the image has been removed/deleted by the user, if so then I may download that also and then I will update my Grid view accordingly. If there is no deleted image then it should show normally.
I searched on internet and I found one method to check if the file is still there "myFile.exists()" but do not know how to use it in my case.
This is the worse point and could be hard of my logic, what Is going on now is I open my activity and it takes the image path from the database and fetch the image into the imageview. but what If there is sime 1 present , image 2 present but not image 3 , image 3 is deleted by user , then Now How to adjust this thing , as we are in the adapter of the gridview, how we would wait and download this image and would fit it at that place ?
Please tell me How to do this and How to check if any of the file has been deleted. ?

How to Store Android Pictures to Prevent User Deletion but Still Give User Access

I'm working on my first real Android application, and I have run into a use case problem for which I cannot seem to find a best practice. The application has a main screen with a RecyclerView that has an ImageView as part of the view that makes up the individual list items. Clicking on an item in the RecyclerView takes you to an Activity with a ViewPager giving details for the selected item and allowing the user to swipe through the details of the items that were displayed in the RecyclerView. As part of the workflow of adding or editing an item, the user can take a picture that is used for generating the thumbnail for the RecyclerView and for display in the details fragment in the ViewPager. I plan to provide the ability for the user to share the detail entry, including the picture, on social media or email or to their Google Photos. My dilema is how the picture should be stored on the user's device. You can store to the public external storage, which is scanned by the media scanner and can be accessed by the user for copying to their computer or sharing.
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName);
However, the user can also delete the pictures stored there which poses a problem for generating thumbnails and display in the detail fragment.
Another approach would be to store the pictures to the applications internal storage, like so:
File file = new File(getExternalFilesDir(null), "DemoFile.jpg");
Of course, this would protect the pictures from being deleted. However, the user would not be able to access that storage location from their computer or from other photo apps on their device.
I could store a copy in both locations. However, that seems like a waste of device space. Are there any best practices for such a use case? Do others have any experience with this scenario that they would be willing to share?
The best approach would be, to upload the picture the User takes to a server via a small .php script, so it is guranteed, that the user cannot simply delete the picture and causing your app to malfunction, while still giving the user the ability to have a local copy of the image(s) on their device.
You could place an empty .nomedia file in the folder of your thumbnails. This will prevent the media scanner from scanning what's inside.
That being said, if you'd like to get these thumbnails automatically deleted when your app gets uninstalled, which I think is what you'd want, you can create a private directory on your external storage that will be tied to your particular application.
By the way, in Android the user is the application itself, so by making a directory private, you're making it private for the application itself (not the actual user of the device). But obviously, if you're saving these thumbnails on a removable sdcard, or if the actual user roots his device, these files won't truly be private.

How do I delete a photo from android phone using BridgeIt?

I hav been playing with new BridgeIt release. I can upload photos great, but does anybody know how to make the web application delete or remove the photo last taken? I know the user can go into photo and delete it manually but that is extra steps. PhoneGap has camera cleanup method which I liked. Is there something similar for bridge it?
Once the photo is uploaded, it's up to the web application to store or delete it. In the case of the BridgeIt demo, photos are uploaded and then automatically deleted after a period of time. In terms of device storage, the photos are captured to temporary files on the device and then uploaded, so will be cleaned up automatically by the operating system.

storing data in device after the first time they are recalled android

I want to do this. my app has many screens and in each of them, on the top, I display an imageView as a logo. So I have 20 screens and that means (20*3) images in my drawable which makes my app be many Mb's. Because this image is static and never changes I want to do this: Getting it from the web (I know how to do it, I am not asking this) only for the first time this screen is ever launched, then this image be stored somewhere in user's device and then use that path as a source. (I mean not download it again, because it will be annoying for the user waiting every time). So is it possible? Will it make my app go slower (not the first time, but the rest) because I am retrieving data from SD?
Yes, you can do this fairly easily. You also do not have to store the data on the SD card necessarily. You can store the image in the internal storage.
Basically, set up a cache directory. When you need the image, check the cache directory, and if the file is not there, download it over http and store the file in the cache directory.
It will change how you get the resource (e.g., you won't be able to use R.drawable.imagename), but you can just load the drawable programmatically.

Categories

Resources