Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
SQLite Provider: Database access made easy
David González
January 29, 2014
Technology
7
300
SQLite Provider: Database access made easy
David González
January 29, 2014
Tweet
Share
More Decks by David González
See All by David González
Building a Multiplatform library for iOS and Android
malmstein
9
950
Unidirectional Data Flow on Android
malmstein
6
430
Introduction to Kotlin Coroutines
malmstein
0
45
A State Container Architecture for mobile applications
malmstein
0
73
Things I wish I knew before starting to work remote
malmstein
0
50
Remote, lonely and productive
malmstein
0
110
The source of all technical debt
malmstein
6
350
Android Architecture Blueprints
malmstein
0
140
Remote and Lonely
malmstein
4
560
Other Decks in Technology
See All in Technology
如何使用 Argo Event& Workflow 快速建置自定義的工作流程 @ #CNTUG #47
line_developers_tw
PRO
0
350
AWS Control TowerとAWS Organizationsを活用した組織におけるセキュリティ設定
fu3ak1
2
580
Motto Go Forward スライドトップと Goを支える文化とコミュニティ してご利用ください 〜なぜ我々はコミュニティにコントリ ビュートするのか〜
luccafort
0
140
Kubernetesの上に作る、統一されたマイクロサービス運用体験
tkuchiki
1
640
GitHub 엔터프라이즈 어카운트 소개 및 엔터프라이즈 서버 구축 경험
posquit0
1
130
Microsoft Power Automate で 始めるRPAと自動化
taikiyoshida
0
1.7k
スタートアップ入社4日目までに考えたAWSのセキュリティ向上/ Startup AWS Security
shonansurvivors
3
2.3k
三越伊勢丹の接客DXを支える「DevOps基盤」とは
imdigitallab
0
240
Research Paper Introduction #98 "NSDI 2022 recap"
cafenero_777
0
180
暗号資産ウォレット入門(MetaMaskの入門~NFTの購入~詐欺の注意事項など)
kayato
2
120
実験!カオスエンジニアリング / How to Chaos Engineering
oracle4engineer
PRO
0
110
AWS CloudShellという推しサービスについて / lt-20220502-jawsug-cli
becominn
0
620
Featured
See All Featured
Streamline your AJAX requests with AmplifyJS and jQuery
dougneiner
125
8.5k
Faster Mobile Websites
deanohume
294
28k
What's in a price? How to price your products and services
michaelherold
229
9.3k
What’s in a name? Adding method to the madness
productmarketing
11
1.5k
How to name files
jennybc
39
58k
Three Pipe Problems
jasonvnalue
89
8.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
Practical Orchestrator
shlominoach
178
8.6k
We Have a Design System, Now What?
morganepeng
35
2.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
343
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
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