Reputation: 1
I have a problem in reading iphone messages inbox in my app,and i used this code :
- (IBAction) read{
NSString *text = @"";
sqlite3 *database;
if(sqlite3_open([@"/var/root/Library/SMS/sms.db" UTF8String], &database) == SQLITE_OK) {
sqlite3_stmt *statement;
const char *sql4 = "SELECT * from message ORDER BY rowid DESC"; // TODO: different for iOS 4.* ???
const char *sql5 = "SELECT * from message ORDER BY rowid DESC";
NSString *osVersion =[[UIDevice currentDevice] systemVersion];
if([osVersion hasPrefix:@"5"]) {
// iOS 5.* -> tested
sqlite3_prepare_v2(database, sql5, -1, &statement, NULL);
} else {
// iOS != 5.* -> untested!!!
sqlite3_prepare_v2(database, sql4, -1, &statement, NULL);
}
// Use the while loop if you want more than just the most recent message
while (sqlite3_step(statement) == SQLITE_ROW) {
if (sqlite3_step(statement) == SQLITE_ROW) {
char *content = (char *)sqlite3_column_text(statement, 0);
text = [NSString stringWithCString: content encoding: NSUTF8StringEncoding];
sqlite3_finalize(statement);
}
}
sqlite3_close(database);
}
showsms.text=text;
NSLog(@"test");
}
but i cant access the "SMS.DB", i have searched on the internet but no one have a problem like this, plz anyone have any idea about my issue write my the code or tell me his way.
Thanks
Upvotes: 0
Views: 1542
Reputation: 1213
The app sandbox doesn't allow you to access that file. Even if you did get it to work, Apple wouldn't allow it in the store.
Upvotes: 4