DroidForums.net is the original Verizon Android Forum! Registered Users do not see these ads. Please Register - It's Free!
Results 1 to 1 of 1

Thread: Caching files

  1. Droid Newbie
    mzimmer74's Avatar
    Member #
    129312
    Join Date
    Oct 2010
    Posts
    1
    Phone
    Enter Current Phone Model Here
    #1

    Caching files

    Hi all,
    I'm new to the Droid (came from Windows mobile) and want to get into programming for it. I'm slowly working my way through the various possibilities and have managed to write a program that downloads an image from a web page and displays it on my screen. However, what I'd like to do is make a local copy of it so when I next run the program it doesn't have to download it again. Now, I know that I could just save it to a file, but I came across an older suggestion on a web site to use the System Cache. They recommend doing this:

    Code:
    URL url = new URL(strUrl);
    URLConnection connection = url.openConnection();
    connection.setUseCaches(true);
    Object response = connection.getContent();
    if (result instanceof Bitmap) {
      Bitmap bitmap = (Bitmap)response;
    }
    Now, it seems like they were saying that this would use the System Cache to automatically save the file and then if I were to call the same method with the same URL it would check the cache first and then download if needed. However, I can't get it to work. I keep getting an exception thrown and can't trace it back to where it's happening (Eclipse won't give me enough info). All I changed in my code was to replace my previous "LoadImage" method with the above.

    Here's my questions:
    1. Is the above code a legitimate way to load the image?
    2. If so, is there possibly a permission that I'm missing?
    3. In general, what Uses-Permission do I need to give to my applications to enable them to manipulate the filesystem?
    4. Is there some better way to accomplish what I'm trying to do?

    Thanks for any help.
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     

Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. .GZ Files
    By tamadabee128 in forum Android Tech Support
    Replies: 2
    Last Post: 04-08-2011, 05:03 PM
  2. Could use some help with 9.png files
    By chevycam94 in forum Droid Themes
    Replies: 6
    Last Post: 06-13-2010, 12:16 PM
  3. APK files
    By appdaddy in forum Android Applications
    Replies: 9
    Last Post: 03-16-2010, 02:25 PM
  4. Editing drawable files in .apk files
    By aufdemrand in forum Android App Developers
    Replies: 0
    Last Post: 01-10-2010, 12:22 AM
  5. Blackberry Files Files Transferred to DROID
    By tblevins in forum Android Tech Support
    Replies: 0
    Last Post: 11-15-2009, 07:54 PM

Search tags for this page

android cache example

,
android cache view
,

android cache viewer

,

android file cache

,
android httpurlconnection cache
,
android setusecache
,

android setusecaches

,
android setusecaches(true) urlconnection
,
android+setusecaches example
,
bitmap caching android
,
how do you view cached copies of web pages from droid
,

image cache d?veloppement android

,
image caching setusecache android
,

setusecaches android

,
when to setusecaches android
Click on a term to search our site for related topics.
Find us on Google+