And this is the code to cache image files.
protected static Map<String, Drawable> cacheThumbs = new HashMap<String, Drawable>();
//code to cache images
if( thumbUri.length() == 0 )
return;
Drawable d = cacheThumbs.get( thumbUri );
if( d == null )
{
String fileName = movie.getId()+"_"+thumbUri.substring( thumbUri.lastIndexOf('/')+1 );
cacheFile = new File( application.getCacheDir(), fileName );
if( !cacheFile.exists() )
{
//Log.v(LOG_TAG,"Fetching "+thumbUri +" and caching in "+cacheFile.getAbsolutePath() );
InputStream bis = (InputStream) new URL(thumbUri).getContent();
BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream( cacheFile ) );
int read = 0;
while( (read = bis.read( buffer )) != -1 )
bos.write( buffer, 0, read );
bis.close();
bos.close();
Log.v(LOG_TAG,thumbUri + " fetched");
}//if
Log.v(LOG_TAG,thumbUri + " in cache");
BufferedInputStream bis = new BufferedInputStream( new FileInputStream( cacheFile ), 9000 );
d = Drawable.createFromStream( bis, "src name");
bis.close();
cacheThumbs.put( thumbUri, d );
Regards,
Stéphane