I'm using assets as standard icons storage but now I have request that these icons should be updated for some cases. I know that I can't touch assets, so do you have any suggestions where to store them?? These files should be pre-installed and updated for some cases. From start I've been thinking about Internal Storage but now I have some doubts. What do you think???
So the solution to this problem was to put current available images in assets. App checks is there anything new every time user logs in, if yes places new images in /data/../images folder. When icons are required, I first check assets and then the storage. In new app releases I include the new icons in the assets folder.
Related
I'm developing an app that has the functionality to upload all video and photo files to an external server, and I would like to offer the user the possibility to empty their photo and video directory...soon there is some easy way to do that? erasing everything at once
I assume your app already has a way to get access to the path to the directory you want to clear, and a permission to access the storage. Now having the path to the directory you could simply
File(pathToDirectory).list().forEach{ it.delete() }
Customize the behavior based on your needs. For example, you could recursively call the function containing the code above to clear a directory and all included subdirectories, or you could leave folders untouched and just delete files. For that, there are fields isFile and isDirectory
I'm developing a desktop java application.
Each users have a panel showing personal information and also a profile image.
The image is added through Swing JFileChooser, stored in a folder and its path saved in a local database as a string.
Everything work, unless that the user have the possibility to change the image.
Changing the image use a jFileChooser again, and is the same as adding the image from the beginning. The new path is stored correctly, but there's a cache memory issue.
Problem is that images are stored in the hard drive with a file name that must be equal to the current user name. Changing image from the app will create a new image in that folder with the same name, overwriting the previous one.
Now:
- If i open the user panel again, the "old" image is shown, because new and old image path are identical and java use the cached image instead of reloading it
- Closing the app and restarting it will solve the problem, so the path is stored correctly in the database and the issue must be related to the cache memory.
Help me pls!
Thanks in advance for your replies
I am downloading a number of images from the server. That happens once in a while (i.e. as needed). I need to know which is more efficient to the operation of my app: do I download the images to a HashMap of images or do I download them and save them as resources in the asset or drawable directory and then access them by id? Please do explain, at least a little, why whichever option is better.
Ideally you need to download all the images to sdcard and store them.
Access them through the file apis and load them using lazy loading to your image views.
If you are going to load all the images in the app resource folders, then it is going to eat up lot of memory. And keep in mind do not cache all the images on to the memory. I would suggest you to use, UniversalImageLoader from my experience. It gives you a bunch of options to play with.
I want to have an image as part of my apk that the user can modify using my app.
I dont want to save it on the SD card. It should not be viewable or editable outside the app.
Where do I need to put the original image, the one I include to be used by default?
In the resources drawble folder? Or the assets folder?
And how do I overwrite that image with a user-generated one? (with the idea that this will be used in the app everywhere instead.)
You cannot overwrite resources not assets contents.
Alternative solution:
What about saving it to the internal directory of an application, which would not be accessible outside of you application scope? and then every time you display a picture, check if the one in internal memory exists, if it does, then display that one instead of the one in drawables
docs: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
You can save files directly on the device's internal storage. By
default, files saved to the internal storage are private to your
application and other applications cannot access them (nor can the
user). When the user uninstalls your application, these files are
removed.
Something very strange is happenning in my app. I am creating 2 folders in the SD card if they not exist, and downloading some images from a URL if they not exist in the SD card.
Sometimes, when I run the application, the program checks if the folders exists and also the images, as they are exists, it continues and there's nothing wrong.
But often when I run the application, it alerts me that the folders not exists and that it didn't even managed to create those folders, and afterwards I'm getting a "File not found exception" when it tries to download the images who already exists in my SD card.
P.S: I tried it with 2 devices and the same happens, sometimes works, sometimes doesn't.
What could be the problem here?
Actually before accessing files from external storage you have to check whether External storage is present (Available) or not on device (It possible if device's sdcard is mounted on System). For this You have to check the sate of External Storage as Mounted or Not.
Look at this Link for more info..
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
Now solution:
If you find external storage is not available then you can store your files at Internal Storage on temporary basis (Then you can move these files to External Storage when it present).
So My link also help you in how to access Internal Storage in Android.