views:

31

answers:

3

i have a database in iphone which is regularly updated. is there a way to find out the date of last update to the database. i just need the date and not the data. also don't want to store the date of update as a extra column.

A: 

I'm not sure if that's accessible, but the database files "last modified date" should work.

If the change counter is enough: that's written in the SQLite database file header at bytes 24..27.

Thomas Mueller
A: 

Along with the data you can insert a new column which stores the current date too...

i.e. If your data comes on 25-9-2010 you store the current date in the database and keep on updating it when ever your data updates.. In this way you can get the last update DATE & TIME without much effort.

hAPPY cODING...

Suriya
+1  A: 

The sqlite file last modification date should give you that info.

NSString *pathLocal;    // Path to your SQlite DB file
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *localAttr = [fileManager attributesOfItemAtPath:pathLocal error:&error];
NSDate *localDate = [localAttr objectForKey:NSFileModificationDate];
// localDate here has the info you're looking for
Zoran Simic
thank you. worked great.
codesburner