I'm developing an iphone app that retrieves the call log information and store it with the number of missed,incoming and received calls over that time. Here, since the call log is a .db file, i have to first access the call log details and extract it using C++ and sqlite.
Can anyone suggest me how to extract the table named "call" from call_history.db database file and store it in a text file?
I don't think that is allowed by Apple to access the call history database... If it is, which I seriously doubt, then you should be able to open it using sqlite3. There are plenty of tutorials available online how to do this but again, I think, if it is even possible, that your app will be rejected for this...
If you still want to try, the call_history.db file is probably a sqlite3 database.
Have a look at the documentation to see how to access it from your code. If you want to analyze the contents first to find out the schema, just use the command line application sqlite3.
Related
I am a Swift newbie currently working on an IOS application, which needs to access an existing static database (size 400kb) of 1 table with about 3300 rows, and 26 columns. This database was initially a CSV file, converted into an SQLite file.
From forums I read online, it is to my understanding that SQLite queries are incredibly fast, and for that reason should be the preferred choice. I will only need to be reading the database and will not perform any writes.
I have found a number of old tutorials online which have utilized Objective-C or tutorials from several years ago which utilize swift 2 or 3. A newer solution I found was to use this SQLite wrapper: https://github.com/stephencelis/SQLite.swift. However, I am not entirely sure how to implement it. I was wondering if it was possible to read directly from my bundled database, or if I had to create a new table and copy from the bundled database.
It looks like SQLite.swift will get the job done for you. From the documentation on the page you linked it looks like you use Connection(pathToDB) to start using the library.
Since you're bundling the database and don't plan on modifying it you should be able to use Bundle.main.path(forResource:, ofType:) to get the path to your bundled database. If you want to modify it, you'll probably want to copy it to the documents directory and then reference that copy.
Another good answer on getting paths to various kinds of bundle resources if you need more help:
How to get path of image form Resource of main bundle
do we have any command line from where i can query the sqlite database, which is created by coding, and stored in the application's default Documents folder?
Turn on file sharing for the app, copy the database file to your Mac, and use the command line tools (sqlite3) that are there.
(Note to the previous editor: I appreciate editing of answers for accuracy, format improvements, and fixing typos...but, if you want to provide completely different information, I suggest providing your own answer instead of changing the meaning of another user's response.)
I'm looking for an easy way to make sense of a SQL file that I've pulled from some application data in an iPhone backup. It's a huge file with bits and pieces of readable data strewn throughout, and right now I'm reduced to using a text editor to pick through it, which will take years.
Are there any simple SQL viewers available that would work for someone with limited technical knowledge? Or is there a way to export the contents of the file to a more easily readable format?
Really appreciate any help!
Try Base, it is a paid app, but they have a free trial if you download outside of the Mac App Store. I use is daily for sqlite db's
I use SQLiteManager.
There are several other sqlite viewers, like Navicat, but I haven't used them personally.
Alternatively, you can just use sqlite on the command line:
sqlite3 path-to-file
.dump
.quit
I currently have an iPhone app that reads data from an external XML file at start-up, and then writes this data to the database (it only reads/writes data that the user's app has not seen before, though)
My concern is that there is going to be a back catalogue of data of several years, and that the first time the user runs the app it will have to read this in and be atrociously slow.
Our proposed solution is to include this data "pre-built" into the applications database, so that it doesn't have to load in the archival data on first-load - that is already in the app when they purchase it.
My question is whether there is a way to automatically populate this data with data from, say, an XML file or something. The database is in SQLite. I would populate it by hand, but obviously this will take a very long time, so I was just wondering if anybody had a more...programmatic solution...
I'm going to flesh out Jason's answer, I've marked my post as a community wiki so I shouldn't get any points for this.
He's not talking about a dummy app - write the app as you normally would, but check to see if the database exists in your main bundle before you call the code that populates the plist. You run that in the simulator, pull out the generated sqllite database, and add it to your project - if you only need to read from it, you can read it from the main bundle directory. If you need to do further writes then copy it into the writable documents area, and use it from there. So basically for the main user, the code to populate the DB would never be called...
The only downside is you also end up including the plist files you are reading from, even though you only need the database. You could make a different build target that was a copy of the main one with the only difference being that it held the plist files, while the main target you built for the app store did not.
Not to take Jason's answering thunder, I can't comment yet so it has to be here.
The nice thing is that you can access the filesystem of the simulator right on your Mac. I am away from mine at the moment or I could tell you exactly where to look, but I just find it by putting the name of the db file into searchlight and just running with that.
You also do not need to wright any code to populate the db since you can use the command line tool to do the initial setup if that is more convenient.
You will need to copy it over though since resources are stored in the read only signed portion of the app bundle.
I had the same problem of you using sqlite, on massive insert it's really slow. So the best way it's provide directly a filled sqlite database.
You have another way, instead of INSERT INTO, to populate a sqlite db. You can produce a csv file for each table and load into the tables using your computer and the sqlite shell:
Just 2 simple commands:
.separator SEPARATOR
.import FILE TABLE
Example:
adslol:~ user$ sqlite3
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .separator ;
sqlite> .import myData.csv nameOfMyTable
sqlite> .quit
I hope it's what you was looking for :)
If you need a good client for sqlite3 try SQLite Manager, it's a Firefox add-ons.
i need to copy this database file and save it in someother location or i can take backup of the db file. is there a way to do this programmatically.
Thanks
Satish
Unless you've jailbroken your iPhone, there's no way of accessing the sqlite3 database directly on the phone.
If you're talking about getting access to the database from your computer, you can do it by grabbing the database files out of the iPhone backup files. To do that, you'll need to grab a copy of Erica Sadun's mdhelper (binary file) command line utility, and run it from the PC you sync your laptop with like so:
mdhelper -files "AddressBook.sqlitedb" -extract -glob
This will create a "~/Desktop/Recovered iPhone Files" directory containing a file called AddressBook.sqlitedb, which you can access directly or query using your programming language of choice.
If you don't trust downloading and running binary files without knowing what they do, you can look at the source on Github and compile it yourself.
the SQL database can be extracted from an iphone backup. I used this software to grab mine and the SMS database.
If you have lots of images/videos in camera roll it can take a while to run.
http://www.supercrazyawesome.com/
Yeah sorry abt that. ok thanks probably i will create a new database using AddressBook Apis
-Satish
You can also take a backup of your iphone and than use one of tools discribed here to identify the file you need.