2011-06-25 37 views
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; 
} 

預先感謝您!

回答

0

由於SQLite的版本爲使用iPhone而設計的,所以網上的SQLite的想法是完全錯誤的..因爲SQLite的文件存儲在只有iPhone ...

一個更新SQLite數據庫的選項你可以編程你的代碼來更新數據庫,當你的應用程序啓動或更新按鈕。這樣做,你可以讀/寫你的數據庫...和你的數據庫將存儲在iPhone ...