I save pictures to my application on sd card. When I go to gallery I can see that pictures. How I can save pictures which I use in application on sd card but they must be invisible in gallery from phone.
Include an empty file named .nomedia in your external files directory (note the dot prefix in the filename). This will prevent Android's media scanner from reading your media files and including them in apps like Gallery or Music.
While storing data add these two lines then the content will automatically be hidden and images not visible in device gallary.
File dstFile = new File(file.getParent(), "." + file.getName());
file.renameTo(dstFile);
It works great for me.
You can alternatively put a dot in front of the folder name by renaming
foldername to .foldername
But putting .nomedia file in folder and .foldername usage will hide all media files in a directory
A large number of android users are storing album covers inside the album folder and .dirname or .nomedia solutions are hiding all from both gallery and music player. The required functionality is hiding from gallery and showing in music player (else there is no reason for not deleting cover pics if we will not see them right? )
Here is the solution ;
Rename all album cover picture files to albumart.jpg
My detailed answer can be found here Stop images on sd card from showing up in gallery?
Related
I need to hide image(not folder) in both file browser and gallery without changing the file location. I tried prefixing the file name with . it hides the image in the file browser but still showing in gallery. Is there any way to hide image from gallery?
Create a .nomedia file in the same (or parent) directory of the image. This will hide all media in the current directory and subdirectories. (The media scanner will not scan this directory).
I need to hide image(not folder) in both file browser and gallery
without changing the file location.
My thought over this problem is
You can change the extension(make file without any extension) so media scanner will not able to detect it.
e.g file name us test.png rename it to only test
When I have so many images to display in a listview when I flow to the bottom of a picture to another there is a 1 second pause. I save the file path in the sd card in the database sqlite internal adapter and therefore in each element is taken before and after the sqlite database from SD card. How do I not have that annoying lag between an image and another? If I view the image grabbing resources such as (R.drawable.image) this does not bother you, I could make images of sd card reached as to the internal resources to the application? Perhaps accidentally memorize the pictures, I should save them for example in Android / data / com.my.app? (Images except the sd card in pictures folder). How can I improve this?
Use the Universal Image Loader for loading the images
imageLoader.displayImage(imageUri, imageView);
https://github.com/nostra13/Android-Universal-Image-Loader
This will resolve your problem.
Is there a way to get all the icons inside the drawable folder? Im looking for a way similar to how one would get all files from a folder on a SD card, like:
ArrayList<File> file = new ArrayList<File>();
File mediaStorageDir = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"directoryName");
With that snipped you get all files inside a folder called directoryName which is located inside the phones pictures folder.
So i was hoping for something like this:
Drawable[] d = getResources().getDrawables() //But this way you could only get one drawable through its id
All the files in the assets folder can be accessed so easily so why note drawables:
String[] files = null;
AssetManager assetManager = getActivity().getAssets();
try {
files = assetManager.list("BookFrames");
} catch (IOException e) {
e.printStackTrace();
}
I could store the pictures in the assets folder and get all of them with the above snippet, however, i was hoping to create an additional res folder where i would store all my image buttons, and other pictures that i use in my app. The advantage of this is that i could store pictures with different resolutions, and hopefully android would return the correct sized image for a certain screen resolution.
The current scenario. I am creating a custom adapter which includes pictures of book covers, and to prevent the pictures looking tiny on certain screens i would need to include many resolutions of the covers. And by using the drawable directory i let android take care of which resolutions to display, there fore i need a way to get all the drawables as a list when populating my adapter (hoping that android would choose the appropriate picture resolution for me).
I saw this tread How to display list of resource drawables
which show a method to do this, but with that method it would get all the pictures (i dont think android will choose the appropriate resulution with that method, it will just collect all pictures).
Imagine making a memory game where each card is a picture, to make that look good on different screens you need many resolutions for those pictures. So placing those pictures inside drawable would let the android engine take care of the choosing. And you would not need code to check users screen size. But maybe its better to use the below and check the screen resolution of the used than choose appropriate asset folder?
assets/pictures/xhdpi/frame1
hdpi/frame1
I was wondering suppose you are creating a space in an blank xml file to store attributes such as shirts if you were to upload an image from your sd card, how would you code the event handler for that?
I'm trying to create a small puzzle game. My problem is to set the folder where the app reads pictures. Is possible to create in the drawable folder another folder called "images", and insert in this folder the pictures that the app reads ?
I'm using:
((SelectImagePreference) findPreference(IMAGE_SOURCE)).setCustomLocation(data.getData());
Use assets folder http://www.wiseandroid.com/post/2010/06/14/Android-Beginners-Intro-to-Resources-and-Assets.aspx