I loo开发者_Python百科k many sample code for storing data into sqlite but it work .How I store this
I am trying to add the the (newLocation.coordinate.latitude,newLocation.coordinate.longitude)
into sqlite database .
I find this (newLocation.coordinate.latitude,newLocation.coordinate.longitude)
from here
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
if (newLocation)
{
// make sure the old and new coordinates are different
if ((oldLocation.coordinate.latitude != newLocation.coordinate.latitude) &&
(oldLocation.coordinate.longitude != newLocation.coordinate.longitude))
{
//I think Here will my sqlite query for storing the newLocation.coordinate.latitude and newLocation.coordinate.longitude
//But I dont know how i store this location into the sqlite database.
}
}
}
How can i do .Can anyone help me out from this.
you can use this statement....
sqlite3_bind_double(stmt, 1, newLocation.coordinate.latitude);
using coredata would be much easier,other wise try storing into a plist.
Its pretty simple in my view, just made a function open sqlite db in it and then write this code
NSString *update = [[NSString alloc] initWithFormat:@"INSERT OR REPLACE INTO table (longitude, latitude) VALUES ('32.333, 74.6655');"];
char * errorMsg;
if (sqlite3_exec (database, [update UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK)
{
NSAssert1(0, @"Error updating tables: %s", errorMsg);
}
NSLog(@"Location Inserted");
`
精彩评论