Kru*_*nal 3 iphone monodevelop xamarin.ios ipad xcode4.2
我是iPad开发的新手.我使用Xcode 4在Objective C中创建了两个或三个iPad应用程序.现在我想使用C#在MonoDevelop工具中创建iPad应用程序.
我想创建一个基本的数据库项目,因为我需要一个使用SQLite数据库的基础教程.我在Google上搜索过,但我没有得到任何教程.
我尝试过SqLiteClient和SqLite-net.我建议你在这里阅读教程: sqlite-net
对我来说,我只是将Sqlite.cs文件放入我的项目中并使用它进行编译.
然后,使用您选择的工具,创建一个SQLite数据库并将其添加到您的MonoTouch项目中,确保将构建标志设置为"内容".一旦你的项目中有了SQLite数据库(把文件放在你喜欢的任何地方),就可以以只读的方式访问它...除非你做类似于下面例子中的代码的东西...重定位文件到您的应用程序(和您的用户)将具有写权限的用户个人文件夹.
如果您在运行时需要用户对数据库执行CRUD操作,则需要在代码中包含以下内容以将文件复制到用户的个人文件夹:
using System.Linq;
using SQLite;
string personalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string dbName = "myDatabase.db";
string dbPath = Path.Combine ( personalFolder, dbName);
// in this example I will always delete and re-copy the db to the users personal folder...
// modify to suit your needs...
if (File.Exists (dbPath) {
File.Delete(dbPath);
}
File.Copy (dbName, dbPath);
// note: myDatabase.db for this example is in the root project folder.
using (var db = new SQLiteConnection(dbPath)) {
// query using Linq...
}
Run Code Online (Sandbox Code Playgroud)
希望有所帮助.
要访问sqlite,你有很多选择,比如
还有很多其他人甚至Apple的CoreData都看到了(http://www.sgmunn.com/?p=1),但我猜任何上述选项都比较简单.
希望这有助于您入门
| 归档时间: |
|
| 查看次数: |
5454 次 |
| 最近记录: |