Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:22:49+00:00 2026-06-03T02:22:49+00:00

So my code is suppose to create a database and table, and then store

  • 0

So my code is suppose to create a database and table, and then store my location data in the table. It’s hitting all the right logs that I made, like “Created Table” and “Location inserted”, but when I go to find the file it’s either (a) not there or (b) there but has no location data in it.

I started off using CoreData, but it quickly turned into a nightmare so I changed to using sqlite directly.

        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {

        locationManager =[[CLLocationManager alloc] init];

        locationManager.delegate = self; 
        locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        locationManager.distanceFilter = 10;
        [locationManager startUpdatingLocation]; 



// Create a string containing the full path to the bold2.db inside the documents folder
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"bold2.sql"];

    // Check to see if the database file already exists
    bool databaseAlreadyExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath];

    // Open the database and store the handle as a data member
    if (sqlite3_open([databasePath UTF8String], &databasehandle) == SQLITE_OK)
    {
        // Create the database if it doesn't yet exists in the file system
        if (!databaseAlreadyExists)
        {
            // Create the LOCATION table
            const char *sqlStatement = "CREATE TABLE IF NOT EXISTS LOCATION (ID INTEGER PRIMARY KEY AUTOINCREMENT, latitude DOUBLE, longitude DOUBLE, timeStamp DATE)";
            char *error;
            if (sqlite3_exec(databasehandle, sqlStatement, NULL, NULL, &error) == SQLITE_OK)
          {
                NSLog(@"Created Table");
                 }
              }

Here is the location delegate where I’m getting a new location and inserting it into the database. The weird thing is that it actually hits the “Location inserted” log.

    -(void) locationManager: (CLLocationManager *) manager
    didUpdateToLocation: (CLLocation *) newLocation
           fromLocation: (CLLocation *) oldLocation
{

    NSString *insertStatement = [NSString stringWithFormat:@"INSERT INTO location (latitude, longitude, timeStamp) VALUES (%g, %g, %g)",newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.timestamp];    
    char *error;   
    if ( sqlite3_exec(databasehandle, [insertStatement UTF8String], NULL, NULL, &error) == SQLITE_OK)
    {
        NSLog(@"Location inserted. %g", newLocation.coordinate.latitude);
    }    

    else NSLog(@"Error: %s", error);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:22:51+00:00Added an answer on June 3, 2026 at 2:22 am

    I solved it. Since I’m remoting into a minimac the file path to the db was hidden. I just pasted the correct filepath in go to folder and found the right file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this database table (some sample code below) that stores the relationship
Suppose I have a table like: create table { id numeric(5,3), code varchar(10) }
Let suppose we've database table my_code Input I'll create connection to this database table
Suppose I have the following: using(var ctx = DataContextFactory.Create(0)) { ... Some code ...
I need to create database objects (table, index, keys, views, functions, etc.) through the
Suppose I have following table in my database: Tbl_Persons: Id Country Name 1 Australia
Suppose I want to create a set of observers based on type. That is
Suppose I have a user table that creates strong relationships (Enforce Foreign Key Constraint)
i'm wondering how am i suppose to update my database data of different records
suppose I have the following tables and relations: CREATE TABLE [dbo].[Customers] ( [CustomerID] [int]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.