Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SQLite Provider: Database access made easy
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
David González
January 29, 2014
Technology
350
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SQLite Provider: Database access made easy
David González
January 29, 2014
More Decks by David González
See All by David González
A comprehensive guide to tracker protection on Android
malmstein
1
98
Building a Multiplatform library for iOS and Android
malmstein
9
1.3k
Unidirectional Data Flow on Android
malmstein
6
560
Introduction to Kotlin Coroutines
malmstein
0
180
A State Container Architecture for mobile applications
malmstein
0
170
Things I wish I knew before starting to work remote
malmstein
0
110
Remote, lonely and productive
malmstein
0
200
The source of all technical debt
malmstein
6
460
Android Architecture Blueprints
malmstein
0
310
Other Decks in Technology
See All in Technology
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
20k
Distributed Transactions Under Fire: Building a Zero-Oversell Flash Sale Platform with Amazon Aurora DSQL
yama3133
1
110
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
130
dbt in Microsoft Fabric
ryomaru0825
0
300
Windows の互換機能 - 古いプログラムはなぜ動作できるのか
murachiakira
PRO
0
130
どんな手を使っても絶対間に合わせるスケジューラ
asari194617
0
1.5k
顧客の要望は2次情報である 〜アンテナを張るFDEの構造論〜
noriakioji
5
1k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.5k
hookで自作する Claude Code の「実況ボード」
shinyasaita
2
230
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
20k
1.5時間を無駄にして学んだwsl2におけるaptとsnapの選択と仕組み
yosaka0123
0
460
LLMアプリ、 雰囲気で運用してませんか? 〜LLMOpsの現在地〜
taka_aki
1
550
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
530
We Have a Design System, Now What?
morganepeng
55
8.3k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
480
Navigating Weather and Climate Data
rabernat
0
490
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Unsuck your backbone
ammeep
672
58k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
How to make the Groovebox
asonas
2
2.4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
300
Transcript
SQLite Provider: A simplification of database access David Gonzalez
Content Providers Managers of structured data Abstract underlying data storage
Allow external access to data
Manage connection to data source
Easy access to data
Implicit intents
Loader callbacks
Provide data to external apps
PROBLEMS — And we had to fix them
Boilerplate code
DB versioning
JSON to SQL mapping
Create the database public ExampleDatabase(Context context, CursorFactory factory, int version)
{ super(context, DATABASE_NAME, factory, version); } @Override public void onCreate(SQLiteDatabase db) { createDatabase(db); }
protected void createDatabase(SQLiteDatabase db) { final String articleTable = "CREATE
TABLE articles" // + " ('" // + _id + "' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, '" // + title + "' TEXT, '" // + content + "' TEXT, '" // + timestamp + "' TIMESTAMP NOT NULL );"; db.execSQL(articleTable); @Override public void onCreate(SQLiteDatabase db) { createDatabase(db); }
Upgrade it @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) { if (oldVersion == 0) { db.execSQL("DROP TABLE article"); createDatabase(db); } }
Upgrade it ContentResolver resolver = getContentResolver(); String[] projection = new
String[] {UserDictionary.Words._ID, UserDictionary.Words.WORD}; String selectionClause = UserDictionary.Words.WORD + " = ?"; String[] selectionArgs = new String[] {"Android"}; String sortOrder = UserDictionary.Words.WORD + " ASC”; Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, projection, selectionClause, selectionArgs, sortOrder);
Our solution https://github.com/novoda/SQLiteProvider