I need make copy from assets to cache pictures.
I have got MD5 file name in assets (image http url).
I made copy as here:
DiskCache diskCache = ImageLoader.getInstance().getDiskCache();
File fileDirectory = diskCache.getDirectory();
copyAssets(context, fileDirectory);
I try read file with UniveralImageLoader as:
ImageLoader.getInstance().displayImage(castle.getImageUrl(), this.castleImage, imageOptions);
but image isn't read.
Any sugestions?
SOLUTION
cache.save(uri, in, copylistener)
Related
i am downloaded and saved images from web to my app cache folder. Now i am trying to convert particular cache folder image(PREM.jpg) into bitmap. For that i am using bellow code.
FileCache file = new FileCache(Context);
File f = file.getFile("PREM.jpg");
Bitmap bitmap = decodeFile(f);
System.out.println("Exist status. " + f.exists());
But i am always getting file not exist (Exist status. false).
Actually "PREM.jpg" file name showing some thing like "-1006685176" in the cache folder.
This is my cache filder
Can you please help me how to i convert that particular image into bitmap.
Thank you everyone.
Prem
I'm having troubles adding a local image to the disk cache manually. The reason is that I have a local photo and I need to upload this. But since I know the URL result, I want to cache this immediately. I'm using
ImageLoader.getInstance().getDiscCache().put(imageUrl, new File(tempFileURI));
But this doesn't work because when I use the line below, the file returns null
File thumb=
DiscCacheUtil.findInCache(urlThumbSize,ImageLoader.getInstance().getDiscCache());
Any idea?
Actually DiscCache is not intended to be used directly. DiscCache.put() doesn't copy your file into disk cache. It just control cache size if it's limited cache.
You should copy image file into cache directory yourself:
File fileInDiscCache = discCache.get(imageUri);
// copy your file into 'fileInDiscCache' file
discCache.put(imageUri, fileInDiscCache);
I use the jmatIO library to read a .mat file. In plain java I can set the path to the matFileReader like this
MatFileReader mfr = new MatFileReader("/theta-phi_small_param5.mat");
and I can have access to all the .mat data. Inside the android i put the .mat file to the assets folder and I tried to access it like this
mfr = new MatFileReader("file:///assets/theta-phi.mat");
but it doesn't work. How can I get the path to the mat file inside the assets folder so to read it with the MatFileReader?
Does the MatFileReader accept an InputStream? If so you can do it like this:
InputStream in = getAssets().open("theta-phi.mat");
It might also work to use:
File file = new File("file:///android_asset/theta-phi.mat");
UPDATE: Since MatFileReader doesn't support InputStream and the File solution above doesn't work I guess your best bet is to copy the file from the Assets folder to your apps External/Internal storage and from there access the file.
I need the route of a pdf file in my Android Project.
The file could be in raw or in assets folder.
I need to get the route because I must call using the File Class
Ex: File file = new File(path);
Thanks
Image:
http://img19.imageshack.us/img19/2303/capturaww.png
I am not quite sure what you mean, assuming you want to read to PDF file in your assets (res file) look here
Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods
But if you want to get the file path of a folder, then look here
how to get file path from sd card in android
How to get the file path from URI?
Here is an example of how to get a file path (taken from the third link)
File myFile = new File(uri.toString());
myFile.getAbsolutePath()
My webview saves lot of cache on SD Card when I visit a site which contains images and they don't show their format. When I try to open them, the default Android file manager says "File type not found". Then I changed the format of some of them(mostly the big size one) to .jpg and bingo, they are the images I saw on the webpage.
Punchline: I want to open the images from that sites that are saved as cache, in another activity, would I have to go on and rename all the cache files to .jpg then call them or there is another way to do it.
Thank you.
You can use the BitmapFactory to open these images files. You can try:
- decodeFile(String pathName)
If it gives some problem with the extension, try decodeStream (InputStream is), it receive an InputStream and it should work.
You can list a folder with File:
File f = new File(Environment
.getExternalStorageDirectory()
.getAbsolutePath());
File[] files = f.listFiles();
for (File file : files){
//Do something with this file
}