iPhone "cannot open database file" for call_history.db in xcode app

I am trying to access the call_history.db database on a jailbroken iPhone. I can access call_history.db for iPhone 4 with iOS 4.1. But the problem is that I cannot access the database in iPhone 3gs with iOS 3.1.3.

When I try to open the database for 3gs, I get the following database error:

unable to open database file

I am using different paths for iOS 4.1 and iOS 3.1.3

  • iOS 4.1 on iPhone 4 - / private / var / wireless / Library / CallHistory / call_history.db

  • and iOS 3.1.3 on iPhone 3gs - / private / var / mobile / Library / CallHistory / call_history.db

Refresh

I am getting call_history.db like this

//NSString *path=@"/private/var/wireless/Library/CallHistory/call_history.db";//for ios 4.0 and above call_history.db
 NSString *path=@"/var/mobile/Library/CallHistory/call_history.db";//for ios 3.0 and above call_history.db

if(sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
   //code for fetching the calls goes here.////

    NSLog(@"call_history present");
}

else {

    NSLog(@"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    sqlite3_close(database);
}

      

Here's the error output:

unable to open database file

I noticed that I cannot access the Library folder on both iPhones with the above code. I can get all files manually via SSH.

+1


source to share


2 answers


Your app is in a sandbox that doesn't have access to anything outside of itself. Let's say your target jailbreak devices are another story.



Xcode will install your application into an isolated environment. You need to manually sign the application using , then copy it to the directory . ldid -S /YourApp.app/YourApp

/Applications

+5


source


These were the best and easiest tutorials I've seen
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/

Instead of hardcoding the path, try below.



databaseName = @"AnimalDatabase.sql";

// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];

      

0


source







All Articles