1

So, the thing is that i've downloaded a couple of photos and stored them in the data/data/project/username directory on the phone and I want to display them (without having to download them again first) every time the user with username is using my application.

So've created a linkedlist with the paths on the phone where these photos are stored and every time a new photo is downloaded I add it to this linked list. Every time the activity is created/stopped i deserialize/serilize the list containning these links.

The serilialization part seems to be working ok, since I checked and the deserialized list seems to contain proper links to the the photos on the phone, but nonetheless when I start this activity nothing appears on the screen (before that I was downloading the photos every time the user logs in and they were displayed properly and everything was fine) and there's no error bumping in logcat or whatsoever. I first thought I had some typo when adding the photo urls to the list, but i checked and everything seems fine. Any ideas? (think)

Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
asenovm
  • 6,397
  • 2
  • 41
  • 52
  • 2
    why do you use serialization manually? In Android there is an object called Bundle that is specifically used to store/retrieved an activity state. Basically when the activity is paused you use the bundle to store your linked list, then you get it back when the activity resumes. Read this question for more info: http://stackoverflow.com/q/151777/422931 – gulbrandr Feb 02 '11 at 14:03
  • thanks for the link, gulbrandr! – asenovm Feb 02 '11 at 20:36
  • you are welcome. So, you resolved your problem? – gulbrandr Feb 03 '11 at 08:24
  • not really so far. I overrode the onSaveInstanceState method and i put the ArrayList instances where i store the paths to the files and the urls from which they've been downloaded in the bundle but it doesn't seem to be working. When i try to get the saved values from the bundle in the onCreate method the bundle is always null. – asenovm Feb 03 '11 at 12:22
  • your list is to be retrieved from the Bundle object in the onRestoreInstanceState method, not in onCreate. – gulbrandr Feb 03 '11 at 19:02

1 Answers1

2

Flickr photos have unique IDs. When you save the photos on the internal storage of the device, use their ID's for names (for example 123456111.jpg). When the user reconnects to Flicker, just check each image in his gallery if it is already downloaded.

It is good to use getCacheDir() for your cache directory, because it is automatically managed by Android.

Kiril Kirilov
  • 11,167
  • 5
  • 49
  • 74
  • the bundle from onSaveInstanceState() where i store the info about the downloaded photos is always null when i try to access it from onCreate :| – asenovm Feb 03 '11 at 13:57
  • http://stackoverflow.com/questions/3730708/how-to-send-an-arraylist-of-custom-objects-in-a-bundle – Kiril Kirilov Feb 03 '11 at 15:16