[フレーム]
Uploaded byShinichiAoyagi
PPTX, PDF23,052 views

Windows ストアーアプリで SQLite を使ってみよう

This document discusses using SQLite with C# in Windows Store apps. It shows how to create a SQLite database in local storage, define a data model class, perform CRUD operations like insert, update, delete. It also demonstrates using asynchronous methods and shows how to sync the local SQLite database with the roaming folder to enable roaming of app data across devices.

Embed presentation

Downloaded 13 times
http://shinichiaoyagi.blogspot.jp/
http://www.sqlite.org/
class Person { [PrimaryKey, AutoIncrement] public int Id { get; set; } [MaxLength(20)] public string Name { get; set; } } using (var con = new SQLiteConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db"))) { con.CreateTable<Person>(); con.Insert(new Person() { Name = "メトロ太郎" }); }
var persons = con.Query<Person>("select * from Person where Id = 1"); class Result { public string Name { get; set; } } var names = con.Query<Result>("select Name from Person where Id = 1");
var person = con.Table<Person>().Where(x => x.Id == 1).First();
con.Execute("update Person set Name='WindowsRT' where Id=1"); var person = con.Table<Person>().Where(x => x.Id == 1).First(); person.Name = "Metro"; con.Update(person);
var con = new SQLiteAsyncConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db")); await con.CreateTableAsync<Person>(); await con.InsertAsync(new Person() { Name = "メトロ太郎" }); var person = await con.Table<Person>().Where(x => x.Id == 1).FirstAsync(); person.Name = "Metro"; await con.UpdateAsync(person); await con.ExecuteAsync("update Person set Name='WindowsRT' where Id=1"); var persons = await con.Table<Person>().ToListAsync();
http://blogs.msdn.com/b/windowsappdev_ja/archive/2012/07/25/roaming.aspx
try { var foamingfile = await Windows.Storage.ApplicationData.Current.RoamingFolder.GetFileAsync("AdressBook.db"); await foamingfile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder); } catch (FileNotFoundException) { } var localfile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("AdressBook.db"); await localfile.CopyAsync(Windows.Storage.ApplicationData.Current.RoamingFolder);
http://msdn.microsoft.com/ja-jp/library/windows/apps/xaml/hh975357.aspx
http://www.microsoft.com/ja-jp/download/details.aspx?id=30674

More Related Content

Single Sign-On with Waffle
PDF
Single Sign-On with Waffle
Automatically Spotting Cross-language Relations
PDF
Automatically Spotting Cross-language Relations
Active Record
KEY
Active Record
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
PDF
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
The love child of Android and .NET: App development with Xamarin
PDF
The love child of Android and .NET: App development with Xamarin
San Francisco Java User Group
PDF
San Francisco Java User Group
Introduction towebmatrix
PPTX
Introduction towebmatrix
Introduction to MongoDB
PPTX
Introduction to MongoDB
Single Sign-On with Waffle
Single Sign-On with Waffle
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
Active Record
Active Record
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
Aprimorando sua Aplicação com Ext JS 4 - BrazilJS
The love child of Android and .NET: App development with Xamarin
The love child of Android and .NET: App development with Xamarin
San Francisco Java User Group
San Francisco Java User Group
Introduction towebmatrix
Introduction towebmatrix
Introduction to MongoDB
Introduction to MongoDB

What's hot

Writing browser extensions_in_kotlin
PDF
Writing browser extensions_in_kotlin
Php5
PPTX
PageObject
PDF
PageObject
Building Your First App with MongoDB
PPT
Building Your First App with MongoDB
WAFFLE: Windows Authentication in Java
PDF
WAFFLE: Windows Authentication in Java
Waffle at NYCJavaSig
PPT
Waffle at NYCJavaSig
Snapshot Testing @ CocoaheadsNL
PDF
Snapshot Testing @ CocoaheadsNL
PhoneGap: Local Storage
PDF
PhoneGap: Local Storage
Form1.vb
PDF
Form1.vb
Using Dojo
PDF
Using Dojo
React.js 20150828
PPT
React.js 20150828
The Ring programming language version 1.8 book - Part 49 of 202
PDF
The Ring programming language version 1.8 book - Part 49 of 202
MongoDBで作るソーシャルデータ新解析基盤
PDF
MongoDBで作るソーシャルデータ新解析基盤
Building Your First App: An Introduction to MongoDB
PDF
Building Your First App: An Introduction to MongoDB
MongoDB全機能解説2
PDF
MongoDB全機能解説2
Basic crud operation
PPTX
Basic crud operation
Introduction to the new official C# Driver developed by 10gen
PPTX
Introduction to the new official C# Driver developed by 10gen
Fast content import in Plone
KEY
Fast content import in Plone
MongoDB NoSQL and all of its awesomeness
PDF
MongoDB NoSQL and all of its awesomeness
Indexing
PDF
Indexing
Writing browser extensions_in_kotlin
Writing browser extensions_in_kotlin
Php5
PageObject
PageObject
Building Your First App with MongoDB
Building Your First App with MongoDB
WAFFLE: Windows Authentication in Java
WAFFLE: Windows Authentication in Java
Waffle at NYCJavaSig
Waffle at NYCJavaSig
Snapshot Testing @ CocoaheadsNL
Snapshot Testing @ CocoaheadsNL
PhoneGap: Local Storage
PhoneGap: Local Storage
Form1.vb
Form1.vb
Using Dojo
Using Dojo
React.js 20150828
React.js 20150828
The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
Building Your First App: An Introduction to MongoDB
Building Your First App: An Introduction to MongoDB
MongoDB全機能解説2
MongoDB全機能解説2
Basic crud operation
Basic crud operation
Introduction to the new official C# Driver developed by 10gen
Introduction to the new official C# Driver developed by 10gen
Fast content import in Plone
Fast content import in Plone
MongoDB NoSQL and all of its awesomeness
MongoDB NoSQL and all of its awesomeness
Indexing
Indexing

Viewers also liked

WindowsストアーアプリでSharpDXを動かしてみる
PPTX
WindowsストアーアプリでSharpDXを動かしてみる
XAML 入門
PPTX
XAML 入門
"なめらか"なメトロスタイルアプリを作るために ~WinRT の非同期性を活用したアプリ開発~
PPT
"なめらか"なメトロスタイルアプリを作るために ~WinRT の非同期性を活用したアプリ開発~
トランザクションの設計と進化
PPTX
トランザクションの設計と進化
LINQ概要
PPTX
LINQ概要
LINQ の概要とかもろもろ
PPTX
LINQ の概要とかもろもろ
WindowsストアーアプリでSharpDXを動かしてみる
WindowsストアーアプリでSharpDXを動かしてみる
XAML 入門
XAML 入門
"なめらか"なメトロスタイルアプリを作るために ~WinRT の非同期性を活用したアプリ開発~
"なめらか"なメトロスタイルアプリを作るために ~WinRT の非同期性を活用したアプリ開発~
トランザクションの設計と進化
トランザクションの設計と進化
LINQ概要
LINQ概要
LINQ の概要とかもろもろ
LINQ の概要とかもろもろ

Similar to Windows ストアーアプリで SQLite を使ってみよう

Windows Azure Storage-Table(1) for IV CSE.pptx
PPTX
Windows Azure Storage-Table(1) for IV CSE.pptx
Cassandraに不向きなcassandraデータモデリング基礎 / Data Modeling concepts for NoSQL weak point
PDF
Cassandraに不向きなcassandraデータモデリング基礎 / Data Modeling concepts for NoSQL weak point
Doodads quickref
PDF
Doodads quickref
greenDAO
PDF
greenDAO
SQLite with UWP
PPTX
SQLite with UWP
ActiveRecord
KEY
ActiveRecord
20131004 - Sq lite sample by Jax
PPTX
20131004 - Sq lite sample by Jax
Database c# connetion
DOC
Database c# connetion
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
PDF
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
Session 8 connect your universal application with database .. builders & deve...
PPTX
Session 8 connect your universal application with database .. builders & deve...
DataMapper
PDF
DataMapper
19 programming sq lite on windows phone 8.1
PPTX
19 programming sq lite on windows phone 8.1
37c
PPTX
37c
Where's My SQL? Designing Databases with ActiveRecord Migrations
PDF
Where's My SQL? Designing Databases with ActiveRecord Migrations
10.Local Database & LINQ
PDF
10.Local Database & LINQ
2012年08月29日 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
PDF
2012年08月29日 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Building your apps for cross platform compatability
PPTX
Building your apps for cross platform compatability
rails-migrations_1
PDF
rails-migrations_1
Cassandraに不向きなcassandraデータモデリング基礎
PDF
Cassandraに不向きなcassandraデータモデリング基礎
by2t3
Zero downtime deploys for Rails apps
PDF
Zero downtime deploys for Rails apps
Windows Azure Storage-Table(1) for IV CSE.pptx
Windows Azure Storage-Table(1) for IV CSE.pptx
Cassandraに不向きなcassandraデータモデリング基礎 / Data Modeling concepts for NoSQL weak point
Cassandraに不向きなcassandraデータモデリング基礎 / Data Modeling concepts for NoSQL weak point
Doodads quickref
Doodads quickref
greenDAO
greenDAO
SQLite with UWP
SQLite with UWP
ActiveRecord
ActiveRecord
20131004 - Sq lite sample by Jax
20131004 - Sq lite sample by Jax
Database c# connetion
Database c# connetion
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
Session 8 connect your universal application with database .. builders & deve...
Session 8 connect your universal application with database .. builders & deve...
DataMapper
DataMapper
19 programming sq lite on windows phone 8.1
19 programming sq lite on windows phone 8.1
37c
37c
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
10.Local Database & LINQ
10.Local Database & LINQ
2012年08月29日 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012年08月29日 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Building your apps for cross platform compatability
Building your apps for cross platform compatability
rails-migrations_1
rails-migrations_1
Cassandraに不向きなcassandraデータモデリング基礎
Cassandraに不向きなcassandraデータモデリング基礎
by2t3
Zero downtime deploys for Rails apps
Zero downtime deploys for Rails apps

More from ShinichiAoyagi

メトロスタイルってなに?
PPTX
メトロスタイルってなに?
メトロスタイルアプリ開発 最初の一歩
PPTX
メトロスタイルアプリ開発 最初の一歩
LINQ 概要 + 結構便利な LINQ to XML
PPTX
LINQ 概要 + 結構便利な LINQ to XML
WPF & Windows Forms on .NET Core 3.0
PPTX
WPF & Windows Forms on .NET Core 3.0
C# と .NET と ・・・
PPTX
C# と .NET と ・・・
ついに日本上陸!Windows Phone 7.5 アプリケーション開発
PPT
ついに日本上陸!Windows Phone 7.5 アプリケーション開発
【18-C-5】C# で iOS/Androidアプリ開発 - Visual Studio 2015 + Xamarin + MVVMCross -
PPTX
【18-C-5】C# で iOS/Androidアプリ開発 - Visual Studio 2015 + Xamarin + MVVMCross -
Xamarin+MVVMCross のあれこれ
PPTX
Xamarin+MVVMCross のあれこれ
うるう秒とタイムゾーン
PPTX
うるう秒とタイムゾーン
Visual Studio 2015 + Xamarin
PPTX
Visual Studio 2015 + Xamarin
メトロスタイルってなに?
メトロスタイルってなに?
メトロスタイルアプリ開発 最初の一歩
メトロスタイルアプリ開発 最初の一歩
LINQ 概要 + 結構便利な LINQ to XML
LINQ 概要 + 結構便利な LINQ to XML
WPF & Windows Forms on .NET Core 3.0
WPF & Windows Forms on .NET Core 3.0
C# と .NET と ・・・
C# と .NET と ・・・
ついに日本上陸!Windows Phone 7.5 アプリケーション開発
ついに日本上陸!Windows Phone 7.5 アプリケーション開発
【18-C-5】C# で iOS/Androidアプリ開発 - Visual Studio 2015 + Xamarin + MVVMCross -
【18-C-5】C# で iOS/Androidアプリ開発 - Visual Studio 2015 + Xamarin + MVVMCross -
Xamarin+MVVMCross のあれこれ
Xamarin+MVVMCross のあれこれ
うるう秒とタイムゾーン
うるう秒とタイムゾーン
Visual Studio 2015 + Xamarin
Visual Studio 2015 + Xamarin

Recently uploaded

Data Donation as Research Method and Pedagogical Tool
PDF
Data Donation as Research Method and Pedagogical Tool
Getting the Best of TrueDEM – November News & Updates
PDF
Getting the Best of TrueDEM – November News & Updates
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
PDF
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
PDF
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
Formulation and Evaluation of herbal peel off mask gel
PPTX
Formulation and Evaluation of herbal peel off mask gel
[DevFest Strasbourg 2025] - NodeJs Can do that !!
PDF
[DevFest Strasbourg 2025] - NodeJs Can do that !!
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
PDF
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
Integrating AI with Meaningful Human Collaboration
PDF
Integrating AI with Meaningful Human Collaboration
How Forklift camera system help to avert forklift accidents
PDF
How Forklift camera system help to avert forklift accidents
PCCC25(設立25年記念PCクラスタシンポジウム):富士通株式会社 テーマ3「FUJITSU-MONAKA series: Arm-based pro...
PDF
PCCC25(設立25年記念PCクラスタシンポジウム):富士通株式会社 テーマ3「FUJITSU-MONAKA series: Arm-based pro...
Accessibility & Inclusion: What Comes Next. Presentation of the Digital Acces...
PDF
Accessibility & Inclusion: What Comes Next. Presentation of the Digital Acces...
Penetration Testing: Enhancing Cyber Defenses Through Realistic Attack Simula...
PPTX
Penetration Testing: Enhancing Cyber Defenses Through Realistic Attack Simula...
Single prompt response by ChatGPT to a product strategy-related task
PDF
Single prompt response by ChatGPT to a product strategy-related task
MuleSoft AI Series : Introduction to MCP
PPTX
MuleSoft AI Series : Introduction to MCP
The Business Benefits of Databricks Unity Catalog_ A Comprehensive Guide.pptx
PPTX
The Business Benefits of Databricks Unity Catalog_ A Comprehensive Guide.pptx
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
PDF
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
Top 10 Local IT Managed Service Providers in Los Angeles
PDF
Top 10 Local IT Managed Service Providers in Los Angeles
Preface to the 41 LLM Documents Collection
PDF
Preface to the 41 LLM Documents Collection
IBM Instana Observability v1.0.277 Administrator – Professional
PDF
IBM Instana Observability v1.0.277 Administrator – Professional
The Best AI Medical Scribe Every Home Health Agency Needs Today
PDF
The Best AI Medical Scribe Every Home Health Agency Needs Today
Data Donation as Research Method and Pedagogical Tool
Data Donation as Research Method and Pedagogical Tool
Getting the Best of TrueDEM – November News & Updates
Getting the Best of TrueDEM – November News & Updates
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
[BDD 2025 - Full-Stack Development] Digital Accessibility: Why Developers nee...
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
Formulation and Evaluation of herbal peel off mask gel
Formulation and Evaluation of herbal peel off mask gel
[DevFest Strasbourg 2025] - NodeJs Can do that !!
[DevFest Strasbourg 2025] - NodeJs Can do that !!
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
[BDD 2025 - Mobile Development] Mobile Engineer and Software Engineer: Are we...
Integrating AI with Meaningful Human Collaboration
Integrating AI with Meaningful Human Collaboration
How Forklift camera system help to avert forklift accidents
How Forklift camera system help to avert forklift accidents
PCCC25(設立25年記念PCクラスタシンポジウム):富士通株式会社 テーマ3「FUJITSU-MONAKA series: Arm-based pro...
PCCC25(設立25年記念PCクラスタシンポジウム):富士通株式会社 テーマ3「FUJITSU-MONAKA series: Arm-based pro...
Accessibility & Inclusion: What Comes Next. Presentation of the Digital Acces...
Accessibility & Inclusion: What Comes Next. Presentation of the Digital Acces...
Penetration Testing: Enhancing Cyber Defenses Through Realistic Attack Simula...
Penetration Testing: Enhancing Cyber Defenses Through Realistic Attack Simula...
Single prompt response by ChatGPT to a product strategy-related task
Single prompt response by ChatGPT to a product strategy-related task
MuleSoft AI Series : Introduction to MCP
MuleSoft AI Series : Introduction to MCP
The Business Benefits of Databricks Unity Catalog_ A Comprehensive Guide.pptx
The Business Benefits of Databricks Unity Catalog_ A Comprehensive Guide.pptx
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
Top 10 Local IT Managed Service Providers in Los Angeles
Top 10 Local IT Managed Service Providers in Los Angeles
Preface to the 41 LLM Documents Collection
Preface to the 41 LLM Documents Collection
IBM Instana Observability v1.0.277 Administrator – Professional
IBM Instana Observability v1.0.277 Administrator – Professional
The Best AI Medical Scribe Every Home Health Agency Needs Today
The Best AI Medical Scribe Every Home Health Agency Needs Today

Windows ストアーアプリで SQLite を使ってみよう

  • 2.
  • 6.
  • 10.
    class Person { [PrimaryKey, AutoIncrement] public int Id { get; set; } [MaxLength(20)] public string Name { get; set; } } using (var con = new SQLiteConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db"))) { con.CreateTable<Person>(); con.Insert(new Person() { Name = "メトロ太郎" }); }
  • 11.
    var persons = con.Query<Person>("select * from Person where Id = 1"); class Result { public string Name { get; set; } } var names = con.Query<Result>("select Name from Person where Id = 1");
  • 12.
    var person = con.Table<Person>().Where(x => x.Id == 1).First();
  • 13.
    con.Execute("update Person set Name='WindowsRT' where Id=1"); var person = con.Table<Person>().Where(x => x.Id == 1).First(); person.Name = "Metro"; con.Update(person);
  • 14.
    var con = new SQLiteAsyncConnection( Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "AdressBook.db")); await con.CreateTableAsync<Person>(); await con.InsertAsync(new Person() { Name = "メトロ太郎" }); var person = await con.Table<Person>().Where(x => x.Id == 1).FirstAsync(); person.Name = "Metro"; await con.UpdateAsync(person); await con.ExecuteAsync("update Person set Name='WindowsRT' where Id=1"); var persons = await con.Table<Person>().ToListAsync();
  • 15.
  • 16.
    try { var foamingfile = await Windows.Storage.ApplicationData.Current.RoamingFolder.GetFileAsync("AdressBook.db"); await foamingfile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder); } catch (FileNotFoundException) { } var localfile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("AdressBook.db"); await localfile.CopyAsync(Windows.Storage.ApplicationData.Current.RoamingFolder);
  • 17.
  • 18.

AltStyle によって変換されたページ (->オリジナル) /