1
我有一個數據庫充滿了用戶名和密碼等,但我需要能夠下載新的數據庫副本每次用戶打開應用程序,甚至更好,使用互聯網讀/寫數據庫,這是最實用的解決方案。讀取/寫入在線SQLite數據庫iPhone
這是目前我用來在本地讀取和寫入數據庫的代碼,主要用於創建將用於在線讀取/寫入數據庫的函數和規則。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
databaseName = @"UserDatabase.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];
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
[self readNamesFromDatabase];
// Query the database for all username,pass,email records and construct the three different array's for each.
[registerForm setHidden:YES];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
return YES;
}
預先感謝您!