首页 > 数据库技术 > 详细

xamarin SQLite路径

时间:2016-08-09 11:56:31      阅读:268      评论:0      收藏:0      [点我收藏+]

xamarin使用SQLite时对应的访问路径各个平台不一样,需要单独引用。下面各平台罗列代码:

Windows8.1:

public SQLiteConnection GetConnection(string dbName) {
            var sqliteFilename = string.Format("{0}.db3", dbName);
            string documentsPath = global::Windows.Storage.ApplicationData.Current.LocalFolder.Path; 
            
            var path = Path.Combine(documentsPath, sqliteFilename);
            return new SQLite.SQLiteConnection(path);
        }

UWP:

public SQLiteConnection GetConnection(string dbName) {
            var sqliteFilename = string.Format("{0}.db3", dbName);
            string documentsPath = global::Windows.Storage.ApplicationData.Current.LocalFolder.Path; 
            
            var path = Path.Combine(documentsPath, sqliteFilename);
            return new SQLite.SQLiteConnection(path);
        }

Android:

public SQLite.SQLiteConnection GetConnection(string dbName)
        {
            var sqliteFilename = string.Format("{0}.db3", dbName);
            string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); 
            var path = Path.Combine(documentsPath, sqliteFilename);
            return new SQLite.SQLiteConnection(path);
        }

IOS:

public SQLite.SQLiteConnection GetConnection(string dbName)
        {
            var sqliteFilename = string.Format("{0}.db3", dbName);
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            string libraryPath = Path.Combine(documentsPath, "..", "Library"); // Library folder
            var path = Path.Combine(libraryPath, sqliteFilename);
           return new SQLite.SQLiteConnection(path);
        }

 

xamarin SQLite路径

原文:http://www.cnblogs.com/zuimengaitianya/p/5752535.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!