@@ -25,6 +25,53 @@ dependencies {
2525}
2626```
2727
28+ ## Usage
29+ ``` java
30+ import android.os.Bundle ;
31+ import android.support.v7.app.AppCompatActivity ;
32+ import android.widget.ListView ;
33+ import com.github.lykmapipo.sqlbrite.migrations.SQLBriteOpenHelper ;
34+ import com.squareup.sqlbrite.BriteDatabase ;
35+ import rx.Subscription ;
36+ import rx.android.schedulers.AndroidSchedulers ;
37+ import rx.schedulers.Schedulers ;
38+
39+ public class MainActivity extends AppCompatActivity {
40+
41+ private BriteDatabase database;
42+ private BriteAdapter adapter;
43+ private Subscription subscription;
44+ private ListView listView;
45+
46+
47+ @Override
48+ protected void onCreate (Bundle savedInstanceState ) {
49+ super . onCreate(savedInstanceState);
50+ setContentView(R . layout. activity_main);
51+ database = SQLBriteOpenHelper . get(getApplicationContext(), " brite" , 1 );
52+ adapter = new BriteAdapter (getApplicationContext());
53+ listView = (ListView ) findViewById(R . id. list);
54+ listView. setAdapter(adapter);
55+ }
56+
57+ @Override
58+ protected void onResume () {
59+ super . onResume();
60+ subscription = database. createQuery(" brites" , " SELECT * FROM brites" )
61+ .mapToList(Brite . MAPPER )
62+ .subscribeOn(Schedulers . io())
63+ .observeOn(AndroidSchedulers . mainThread())
64+ .subscribe(adapter);
65+ }
66+
67+ @Override
68+ protected void onPause () {
69+ super . onPause();
70+ subscription. unsubscribe();
71+ }
72+ }
73+ ```
74+
2875## Migrations
2976All migrations must be named after database version. So if you start a new project your first migration will be ` 1.yaml ` .
3077When upgrading to new version the the migration file must have the name corresponding to the new database version i.e
0 commit comments