Presentation is loading. Please wait.

Presentation is loading. Please wait.

Xamarin with SQLite Telerik School Academy Xamarin apps for iOS, Android & WinPhone.

Similar presentations


Presentation on theme: "Xamarin with SQLite Telerik School Academy Xamarin apps for iOS, Android & WinPhone."— Presentation transcript:

1 Xamarin with SQLite Telerik School Academy http://schoolacademy.telerik.com Xamarin apps for iOS, Android & WinPhone

2 1. Architecture 2. Install SQLite.NET – for PCL Project 3. Implementation  Shared code  Android  iOS  Windows Phone 2

3 3

4 4

5  PCL – Portable Class Library  Install SQLite.Net PCL from NuGet 5

6 6

7  Initial database setup requires platform-specific work  Use Interfaces to abstract any platform-specific functionality  Use the DependencyService to obtain an implementation public interface ISQLite { SQLiteConnection GetConnection(); SQLiteConnection GetConnection();} 7 public ItemDatabase() { SQLiteConnection database = DependencyService SQLiteConnection database = DependencyService.Get<ISQLite>().GetConnection(); InitializeDatabase(database); InitializeDatabase(database);}

8  Create Table  Read item/s from database  Create/Add item to the database  Delete item from the database  Updata item in the database database.CreateTable<T>(); 8 database.Table<T>(); database.Insert(item); database.Delete<T>(item); database.Update(item);

9 9

10  Add SQLite.PCL – XamarinAndroid Platform from NuGet  Database location var sqliteFilename = "SQLite.db3"; string docPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); (System.Environment.SpecialFolder.Personal); var path = Path.Combine(docPath, sqliteFilename); 10

11  Implement ISQLite  Add assembly Dependency 11 [assembly: Dependency (typeof (SQLite_Android))] public class SQLite_Android : ISQLite { public SQLiteConnection GetConnection () { public SQLiteConnection GetConnection () { var path =...; var path =...; var connection = new SQLiteConnection( var connection = new SQLiteConnection( new SQLitePlatformAndroid(), path); new SQLitePlatformAndroid(), path); return connection; return connection; }}

12 12

13  Add SQLite.PCL – XamarinIOS Platform from NuGet  Database location var sqliteFilename = "SQLite.db3"; string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); string libraryPath = Path.Combine (documentsPath, "..", "Library"); var path = Path.Combine(libraryPath, sqliteFilename); 13

14  Implement ISQLite  Add assembly Dependency [assembly: Dependency (typeof (SQLite_iOS))] public class SQLite_iOS : ISQLite { public SQLiteConnection GetConnection () { public SQLiteConnection GetConnection () { var path =...; var path =...; var connection = new SQLiteConnection( var connection = new SQLiteConnection( new SQLitePlatformIOS(), path); new SQLitePlatformIOS(), path); return connection; return connection; }} 14

15 15

16  Windows Phone does not include the SQLite database engine  Download and Install Precompiled Binaries for Windows Phone 8 Precompiled Binaries for Windows Phone 8Precompiled Binaries for Windows Phone 8  Add References  Windows Phone SDK 8.0 > Extentions > SQLite 16

17  Add SQLite.PCL – WindowsPhone8 Platform from NuGet  Implement ISQLite var sqliteFilename = "SQLite.db3"; string path = Path.Combine( ApplicationData.Current.LocalFolder.Path, ApplicationData.Current.LocalFolder.Path, sqliteFilename); sqliteFilename); 17

18  Implement ISQLite  Add assembly Dependency [assembly: Dependency (typeof (SQLite_WinPhone))] public class SQLite_WinPhone : ISQLite { public SQLiteConnection GetConnection () { public SQLiteConnection GetConnection () { var path =...; var path =...; var connection = new SQLiteConnection( var connection = new SQLiteConnection( new SQLitePlatformWP8(), path); new SQLitePlatformWP8(), path); return connection; return connection; }} 18

19 Live Demo 19

20  Architecture  Install SQLite.NET  For PCL Project  Implementation  Shared code  Android  iOS  Windows Phone 20

21 форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране http://academy.telerik.com

22  C# Programming @ Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Academy @ Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com


Download ppt "Xamarin with SQLite Telerik School Academy Xamarin apps for iOS, Android & WinPhone."

Similar presentations


Ads by Google