开发者

Reading/Writing an online SQLite Database iPhone

开发者 https://www.devze.com 2023-03-15 05:14 出处:网络
I\'ve got a database full of usernames and passwords etc. But i need to able to either download a fresh copy of the database every time the user opens the applciation, or even better, read/write to th

I've got a database full of usernames and passwords etc. But i need to able to either download a fresh copy of the database every time the user opens the applciation, or even better, read/write to the database using the internet, which is the most practical solution.

This is currently the code that i am using to read a开发者_JAVA百科nd write to the database locally, this was mainly for the purpose of creating the functions and rules that will be used to read/write to the database online.

- (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;
}

Thank you in advance!


Since SQLite version is specifically designed for using in iPhone, so the idea of online SQLite is totally wrong.. since SQLite file is stored in iPhone only...

One of the option of updating your SQLite database is you can program your code to update database when your app starts or on update button. Doing this you can Read/Write your database... and your database will be stored on iPhone...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号