Code example for File

Methods: exists, getAbsolutePath

0
	} 
 
	public Drawable retrieveNetworkDrawable(String url) {
		try { 
			String name = url.hashCode() + ".png";
			File f = new File(TiApplication.getInstance().getCacheDir()
					.getAbsolutePath() 
					+ name);
			if (!f.exists())
				downloadImage(_proxy.resolveUrl(null, url), f);
			return Drawable.createFromPath(f.getAbsolutePath());
		} catch (Exception e) {
			Util.e("Hit exception while downloading image " + url, e);
		} 
		return null; 
	} 
 
	private void downloadImage(String url, File f) throws IOException {
		URL myFileUrl = new URL(url);
		HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
		conn.setDoInput(true);