Comparing online and local device date for an image? Need suggestions.

Hi, Previously I have posted this question in another thread but now I am making separate thread for this problem.

My scenario is that, I read the XML from online handler and get Images name from it. The XML also contains the updateTime of the Image. First I save the Images to the device without checking updateTime. Second time when I open the image I have to check that if the updateTime in the XML is updated then I have to re-download the image as well. As I am unable to check the MetaData so currently I do this by comparing Image file modifiedDate and XML updateTime. But can be cases where the device time is not correct. So i don't want to depend on the device time. Any Sugggestions?

I am reading an Image from an Online handler and saving the image on device using the following code,

I then read the image from device and create an EncodedImage from it. But by using enc.getMetaData() I am able to get the key names. But there values are always null. Is there any API through which I can manually add the MetaData? What should I do?

Re: Comparing online and local device date for an image? Need suggestions.

Sorry I can't answer the question about putting metadata in the image you store - that does not seem to be possible, but I have never tried.

What I can say is that the time on the device and the time on the Server can be different, even when both are 'correct', because of time zone differences. So you need to factor in Time Zones.

Obviously if the date is set incorrectly on the device, then this is not going to work.

I would have thought that in most cases the modified time on device will work, and if you get an image down where the XML Update date is after the time on the device (after factoring in any Time Zone differences, then the time on the device is clearly wrong and perhaps you should tell the user that.

Re: Comparing online and local device date for an image? Need suggestions.

Yes I am neutralizing the both dates (online image date & device modified date) by adding/removing the Time Zone offset. But there is difference of 5 to 6 minutes. Lets say I downloaded the image and within 5 minutes I update the online image then Image on the device is never updated because device time is 5 to 6 minutes ahead of online time after removing offsets. This makes me think that if the device time is totally wrong. Lets say if it is 15 minute ahead then it will not update the image for 15 minutes and if the device time is 15 minutes behind then it will always update the image within 15 minutes. I need to somehow save the online time.

I also tried to append the online time with the Image name. Then I listed all the files in the directory and split the file names and check the name part of the file and returned the filename with time. But I am downloading images in 3 threads. 1 main thread with 2 parallel threads and online time is not available in threads. Also it makes code more messy. So i need alterntive to EXIF data. Thanks

Re: Comparing online and local device date for an image? Need suggestions.

Hi @maadani, I have tried to use the ExtendedFileConnection. But image is till saved by the input stream of HttpConnection. ExtendedFileConnection cannot be used to read images from server. I have to create InputStream using HttpConnection. So basically the image is saved on device by HttpConnection and if I read the file through ExtendedFileConnection then it is of no use.