Reputation: 2217
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.
Upvotes: 1
Views: 858
Reputation: 10333
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
Upvotes: 2
Reputation: 9740
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...
Upvotes: 0
Reputation: 50087
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.
Upvotes: 0