i have a database in iphone which is regularly updated. is there a way to find out the date of last update to the da开发者_JAVA百科tabase. i just need the date and not the data. also don't want to store the date of update as a extra column.
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
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.
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...
精彩评论