here is my code to create a new encrypted database
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
const char* key = "sssri"; //the key to encrypt the database
sqlite3_key(db, key, strlen(key)); //using the SQLCipher to encrypt database
if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
NSLog(@"password is correct, or, database has been initialized"); //this step is also successful
if(sqlite3_exec(db, (const char*)"create Table student (name char(4) primary key,class varchar(50) not null)", NULL, NULL, NULL)== SQLITE_OK)
{
NSLog(@"create a table") //create a table if not the database is empty,and create successfully
; }
} else {
NSLog(@"incorrect password!");
}
sqlite3_close(db);
but when i try to open the sqlite database in my app documents using the SqliteManger tool ,i input the "sssri" key ,the database can't be opened correctly.
Why?Some help will be appreciated!