SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Content Providers in Android
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Overall structure
                                                    Application #2
 Application #1
                                                     Activity #1
  Activity #1

  Activity #2             Content Provider          Application #3

  Activity #3                                        Activity #1

                                                     Activity #2




                                              Remote
Database          Files         XML                                …
                                             connection
Content Provider is a source
                                                    Application #2
 Application #1
                                                     Activity #1
  Activity #1

  Activity #2             Content Provider          Application #3

  Activity #3                                        Activity #1

                                                     Activity #2




                                              Remote
Database          Files         XML                                …
                                             connection
For some consumers
                                                    Application #2
 Application #1
                                                     Activity #1
  Activity #1

  Activity #2             Content Provider          Application #3

  Activity #3                                        Activity #1

                                                     Activity #2




                                              Remote
Database          Files         XML                                …
                                             connection
Gives access to variety types of data
                                                     Application #2
  Application #1
                                                      Activity #1
   Activity #1

   Activity #2             Content Provider          Application #3

   Activity #3                                        Activity #1

                                                      Activity #2




                                               Remote
 Database          Files         XML                                …
                                              connection
Overall structure
                                                    Application #2
 Application #1
                                                     Activity #1
  Activity #1

  Activity #2             Content Provider          Application #3

  Activity #3                                        Activity #1

                                                     Activity #2




                                              Remote
Database          Files         XML                                …
                                             connection
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Interaction with Content Provider
                                                    Application #2
 Application #1
                                                     Activity #1
  Activity #1

  Activity #2             Content Provider          Application #3

  Activity #3                                        Activity #1

                                                     Activity #2




                                              Remote
Database          Files         XML                                …
                                             connection
Activity to Content Provider access
Activity


   Cursor        ContentResolver   Content Provider




 CursorAdapter       ListView
Activity
Activity


   Cursor        ContentResolver   Content Provider




 CursorAdapter       ListView
Performing request

                                Content Provider

                                Query

                                Insert
ContentResolver       URI
                                Update

                                Delete
URI



content://com.example.provider/articles

 Scheme          Authority       Path
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Constructing query



SELECT _id, title, content, date
FROM articles
WHERE date >= 1352470000
ORDER BY date ASC
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Constructing query
String[] mProjection =
    {
        "_id",
        "title",
        "content",
        "date",
    };
String mSelection = "date >= ?";
String[] mSelectionArgs = {"1352470000"};
String mSortOrder = "date ASC";
Cursor cursor = getContentResolver().query(
        MyContentProvider.ARTICLES_CONTENT_URI,
        mProjection,
        mSelection,
        mSelectionArgs,
        mSortOrder);
Cursor
      _id                title             content           date
1             First article        Lorem ipsum...      1352475013
2             Second article       Dolor sit amet...   1352471413
...           ...                  ...                 ...




      if (mCursor != null) {
          while (mCursor.moveToNext()) {
              String title = mCursor.getString(Columns.TITLE);
          }
      }
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Activity & blocking queries
Activity


   Cursor        ContentResolver   Content Provider




 CursorAdapter       ListView
Activity & non blocking queries
Activity

CursorLoader



     Cursor         ContentResolver

                                        Content Provider

                    AsyncQueryHandler




    CursorAdapter        ListView
Activity & Loader
Activity

CursorLoader



     Cursor          ContentResolver

                                         Content Provider

                     AsyncQueryHandler




    CursorAdapter         ListView
Activity & Loader
public class ArticlesActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
...
getSupportLoaderManager().initLoader(0, null, this);
...
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            this,            // context
            MyContentProvider.ARTICLES_CONTENT_URI,
            mProjection,
            mSelection,
            mSelectionArgs,
            mSortOrder);
}

public void onLoadFinished(
        Loader<Cursor> loader,
        Cursor cursor) {
    mAdapter.swapCursor(cursor);
}
Activity & Loader
public class ArticlesActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
...
getSupportLoaderManager().initLoader(0, null, this);
...
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            this,            // context
            MyContentProvider.ARTICLES_CONTENT_URI,
            mProjection,
            mSelection,
            mSelectionArgs,
            mSortOrder);
}

public void onLoadFinished(
        Loader<Cursor> loader,
        Cursor cursor) {
    mAdapter.swapCursor(cursor);
}
Activity & Loader
public class ArticlesActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
...
getSupportLoaderManager().initLoader(0, null, this);
...
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            this,            // context
            MyContentProvider.ARTICLES_CONTENT_URI,
            mProjection,
            mSelection,
            mSelectionArgs,
            mSortOrder);
}

public void onLoadFinished(
        Loader<Cursor> loader,
        Cursor cursor) {
    mAdapter.swapCursor(cursor);
}
Activity & Loader
public class ArticlesActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
...
getSupportLoaderManager().initLoader(0, null, this);
...
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            this,            // context
            MyContentProvider.ARTICLES_CONTENT_URI,
            mProjection,
            mSelection,
            mSelectionArgs,
            mSortOrder);
}

public void onLoadFinished(
        Loader<Cursor> loader,
        Cursor cursor) {
    mAdapter.swapCursor(cursor);
}
Activity & Loader
public class ArticlesActivity extends FragmentActivity implements
LoaderCallbacks<Cursor> {
...
getSupportLoaderManager().initLoader(0, null, this);
...
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(
            this,            // context
            MyContentProvider.ARTICLES_CONTENT_URI,
            mProjection,
            mSelection,
            mSelectionArgs,
            mSortOrder);
}

public void onLoadFinished(
        Loader<Cursor> loader,
        Cursor cursor) {
    mAdapter.swapCursor(cursor);
}
Activity & AsyncQueryHandler
Activity

CursorLoader



     Cursor         ContentResolver

                                        Content Provider

                    AsyncQueryHandler




    CursorAdapter        ListView
Activity & AsyncQueryHandler
private AsyncQueryHandler mHandler;

...



mHandler = new MyAsyncQueryHandler(getContentResolver());
mHandler.startQuery(
    0,                // token
    null,             // cookie
    MyContentProvider.ARTICLES_CONTENT_URI,
    mProjection,
    mSelection,
    mSelectionArgs,
    mSortOrder);
Activity & AsyncQueryHandler

class MyAsyncQueryHandler extends AsyncQueryHandler {
    public MyAsyncQueryHandler(ContentResolver cr) {
        super(cr);
    }

    @Override
    protected void onQueryComplete(
            int token,
            Object cookie,
            Cursor cursor) {
        mAdapter.swapCursor(cursor);
    }
}
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Permissions

<permission
    android:name="com.example.provider.permission.READ_ARTICLES"
    android:protectionLevel="normal" />



<provider android:name=".MyContentProvider"
    android:exported="false"
    android:authorities="com.example.provider"
    android:permission="com.example.provider.permission.READ_ARTICLES"
/>



<uses-permission
    android:name="com.example.provider.permission.READ_ARTICLES" />
Permissions

<permission
    android:name="com.example.provider.permission.READ_ARTICLES"
    android:protectionLevel="normal" />



<provider android:name=".MyContentProvider"
    android:exported="false"
    android:authorities="com.example.provider"
    android:permission="com.example.provider.permission.READ_ARTICLES"
/>



<uses-permission
    android:name="com.example.provider.permission.READ_ARTICLES" />
Permissions

<permission
    android:name="com.example.provider.permission.READ_ARTICLES"
    android:protectionLevel="normal" />



<provider android:name=".MyContentProvider"
    android:exported="false"
    android:authorities="com.example.provider"
    android:permission="com.example.provider.permission.READ_ARTICLES"
/>



<uses-permission
    android:name="com.example.provider.permission.READ_ARTICLES" />
●
    Overall structure
●
    Interaction with Content Provider
●
    Constructing query
●
    Retreiving cursor asyncronuously
●
    Provider permissions
●
    Creating Content Provider
●
    Questions
Creating content provider
public class MyContentProvider extends ContentProvider {
...


onCreate()
query()
insert()
update()
delete()
getType()
URI matching


content://com.example.provider/articles
content://com.example.provider/articles/*
content://com.example.provider/articles/#
URI matching


content://com.example.provider/articles
content://com.example.provider/articles/*
content://com.example.provider/articles/#
URI matching


content://com.example.provider/articles
content://com.example.provider/articles/*
content://com.example.provider/articles/#
URI matching
sUriMatcher.addURI("com.example.provider", "articles/#", 0);

sUriMatcher.addURI("com.example.provider", "articles/today", 1);

sUriMatcher.addURI("com.example.provider", "articles/history/*", 2);

...


public String getType(Uri uri) {
    switch (sUriMatcher.match(uri)) {
...
URI matching
sUriMatcher.addURI("com.example.provider", "articles/#", 0);

sUriMatcher.addURI("com.example.provider", "articles/today", 1);

sUriMatcher.addURI("com.example.provider", "articles/history/*", 2);

...


public String getType(Uri uri) {
    switch (sUriMatcher.match(uri)) {
...
MIME types
getType()

vnd.android.cursor.dir/vnd.com.example.provider.article

vnd.android.cursor.item/vnd.com.example.provider.article



getStreamTypes()

{ "image/jpeg", "image/png", "image/gif" }
MIME types
getType()

vnd.android.cursor.dir/vnd.com.example.provider.article

vnd.android.cursor.item/vnd.com.example.provider.article



getStreamTypes()

{ "image/jpeg", "image/png", "image/gif" }
Questions



Thank you!
Useful links
http://developer.android.com/guide/topics/providers/content-provider-basics.html

http://developer.android.com/guide/topics/providers/content-provider-creating.html

http://developer.android.com/guide/topics/security/permissions.html

http://gdg.org.ua

http://dnipro.gdg.org.ua
About speaker
 Alexey Ustenko — Android developer
 Coordniator of GDG Dnipropetrovs'k




 @ustav

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture14Slides.ppt
Lecture14Slides.pptLecture14Slides.ppt
Lecture14Slides.pptVideoguy
 
Active Server Page - ( ASP )
Active Server Page - ( ASP )Active Server Page - ( ASP )
Active Server Page - ( ASP )MohitJoshi154
 
Krazykoder struts2 internationalization
Krazykoder struts2 internationalizationKrazykoder struts2 internationalization
Krazykoder struts2 internationalizationKrazy Koder
 
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)uEngine Solutions
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1Vikas Pandey
 
CSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachCSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachbutest
 
Android and firebase database
Android and firebase databaseAndroid and firebase database
Android and firebase databaseNILESH SAWARDEKAR
 
Mendix rest services
Mendix rest servicesMendix rest services
Mendix rest servicesG Acellam
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.netHemant Sankhla
 

Was ist angesagt? (20)

Lecture14Slides.ppt
Lecture14Slides.pptLecture14Slides.ppt
Lecture14Slides.ppt
 
Simple Data Binding
Simple Data BindingSimple Data Binding
Simple Data Binding
 
Active Server Page - ( ASP )
Active Server Page - ( ASP )Active Server Page - ( ASP )
Active Server Page - ( ASP )
 
Krazykoder struts2 internationalization
Krazykoder struts2 internationalizationKrazykoder struts2 internationalization
Krazykoder struts2 internationalization
 
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)
웹기반 Ajax개발을 위한 프레임워크 - metaworks3 (메타웍스3)
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1
 
CSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approachCSCI6505 Project:Construct search engine using ML approach
CSCI6505 Project:Construct search engine using ML approach
 
Android and firebase database
Android and firebase databaseAndroid and firebase database
Android and firebase database
 
REST
RESTREST
REST
 
Mendix rest services
Mendix rest servicesMendix rest services
Mendix rest services
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.net
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
 
Database connectivity in asp.net
Database connectivity in asp.netDatabase connectivity in asp.net
Database connectivity in asp.net
 
ASP.NET- database connectivity
ASP.NET- database connectivityASP.NET- database connectivity
ASP.NET- database connectivity
 
Data Binding
Data BindingData Binding
Data Binding
 
Metaworks3
Metaworks3Metaworks3
Metaworks3
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Lab2-android
Lab2-androidLab2-android
Lab2-android
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 

Ähnlich wie Content providers in Android

Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipsePeter Friese
 
MongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB
 
High Availability HPC ~ Microservice Architectures for Supercomputing
High Availability HPC ~ Microservice Architectures for SupercomputingHigh Availability HPC ~ Microservice Architectures for Supercomputing
High Availability HPC ~ Microservice Architectures for Supercomputinginside-BigData.com
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021Jason Flax
 
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
[MongoDB.local Bengaluru 2018] Introduction to MongoDB StitchMongoDB
 
KeepIt Course 4: Putting storage, format management and preservation planning...
KeepIt Course 4: Putting storage, format management and preservation planning...KeepIt Course 4: Putting storage, format management and preservation planning...
KeepIt Course 4: Putting storage, format management and preservation planning...JISC KeepIt project
 
Orion Context Broker Webminar
Orion Context Broker WebminarOrion Context Broker Webminar
Orion Context Broker WebminarFIWARE
 
Orion Context Broker webminar 2014 01-22
Orion Context Broker webminar 2014 01-22Orion Context Broker webminar 2014 01-22
Orion Context Broker webminar 2014 01-22Fermin Galan
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications Juliana Lucena
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Netflix Play API: Why we built an evolutionary architecture
Netflix Play API: Why we built an evolutionary architectureNetflix Play API: Why we built an evolutionary architecture
Netflix Play API: Why we built an evolutionary architectureSuudhan Rangarajan
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchMongoDB
 
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a Crawler
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a CrawlerCSCI 494 - Lect. 3. Anatomy of Search Engines/Building a Crawler
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a CrawlerSean Golliher
 
IRJET- A Key-Policy Attribute based Temporary Keyword Search Scheme for S...
IRJET-  	  A Key-Policy Attribute based Temporary Keyword Search Scheme for S...IRJET-  	  A Key-Policy Attribute based Temporary Keyword Search Scheme for S...
IRJET- A Key-Policy Attribute based Temporary Keyword Search Scheme for S...IRJET Journal
 
Interoperable Component Patterns
Interoperable Component PatternsInteroperable Component Patterns
Interoperable Component PatternsMatthew Beale
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyPeter R. Egli
 

Ähnlich wie Content providers in Android (20)

Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with Eclipse
 
MongoDB Stitch Introduction
MongoDB Stitch IntroductionMongoDB Stitch Introduction
MongoDB Stitch Introduction
 
Android開発の基礎_20101218
Android開発の基礎_20101218Android開発の基礎_20101218
Android開発の基礎_20101218
 
High Availability HPC ~ Microservice Architectures for Supercomputing
High Availability HPC ~ Microservice Architectures for SupercomputingHigh Availability HPC ~ Microservice Architectures for Supercomputing
High Availability HPC ~ Microservice Architectures for Supercomputing
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021
 
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
 
KeepIt Course 4: Putting storage, format management and preservation planning...
KeepIt Course 4: Putting storage, format management and preservation planning...KeepIt Course 4: Putting storage, format management and preservation planning...
KeepIt Course 4: Putting storage, format management and preservation planning...
 
internet
internetinternet
internet
 
Orion Context Broker Webminar
Orion Context Broker WebminarOrion Context Broker Webminar
Orion Context Broker Webminar
 
Orion Context Broker webminar 2014 01-22
Orion Context Broker webminar 2014 01-22Orion Context Broker webminar 2014 01-22
Orion Context Broker webminar 2014 01-22
 
Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
 
MongoDB for Genealogy
MongoDB for GenealogyMongoDB for Genealogy
MongoDB for Genealogy
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Netflix Play API: Why we built an evolutionary architecture
Netflix Play API: Why we built an evolutionary architectureNetflix Play API: Why we built an evolutionary architecture
Netflix Play API: Why we built an evolutionary architecture
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a Crawler
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a CrawlerCSCI 494 - Lect. 3. Anatomy of Search Engines/Building a Crawler
CSCI 494 - Lect. 3. Anatomy of Search Engines/Building a Crawler
 
IRJET- A Key-Policy Attribute based Temporary Keyword Search Scheme for S...
IRJET-  	  A Key-Policy Attribute based Temporary Keyword Search Scheme for S...IRJET-  	  A Key-Policy Attribute based Temporary Keyword Search Scheme for S...
IRJET- A Key-Policy Attribute based Temporary Keyword Search Scheme for S...
 
Interoperable Component Patterns
Interoperable Component PatternsInteroperable Component Patterns
Interoperable Component Patterns
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 

Mehr von Alexey Ustenko

Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Alexey Ustenko
 
Android Support Library
Android Support LibraryAndroid Support Library
Android Support LibraryAlexey Ustenko
 
Верстка для Андроид
Верстка для АндроидВерстка для Андроид
Верстка для АндроидAlexey Ustenko
 
Разработка приложений для Android Honeycomb: ActionBar & Fragments
Разработка приложений для Android Honeycomb: ActionBar & FragmentsРазработка приложений для Android Honeycomb: ActionBar & Fragments
Разработка приложений для Android Honeycomb: ActionBar & FragmentsAlexey Ustenko
 
Android application structure
Android application structureAndroid application structure
Android application structureAlexey Ustenko
 
Разработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровРазработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровAlexey Ustenko
 

Mehr von Alexey Ustenko (9)

Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.
 
Ci for Android
Ci for AndroidCi for Android
Ci for Android
 
Android Support Library
Android Support LibraryAndroid Support Library
Android Support Library
 
Верстка для Андроид
Верстка для АндроидВерстка для Андроид
Верстка для Андроид
 
Разработка приложений для Android Honeycomb: ActionBar & Fragments
Разработка приложений для Android Honeycomb: ActionBar & FragmentsРазработка приложений для Android Honeycomb: ActionBar & Fragments
Разработка приложений для Android Honeycomb: ActionBar & Fragments
 
Android application structure
Android application structureAndroid application structure
Android application structure
 
Android overview
Android overviewAndroid overview
Android overview
 
Android tools
Android toolsAndroid tools
Android tools
 
Разработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровРазработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеров
 

Kürzlich hochgeladen

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Kürzlich hochgeladen (20)

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 

Content providers in Android

  • 2. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 3. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 4. Overall structure Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 5. Content Provider is a source Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 6. For some consumers Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 7. Gives access to variety types of data Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 8. Overall structure Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 9. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 10. Interaction with Content Provider Application #2 Application #1 Activity #1 Activity #1 Activity #2 Content Provider Application #3 Activity #3 Activity #1 Activity #2 Remote Database Files XML … connection
  • 11. Activity to Content Provider access Activity Cursor ContentResolver Content Provider CursorAdapter ListView
  • 12. Activity Activity Cursor ContentResolver Content Provider CursorAdapter ListView
  • 13. Performing request Content Provider Query Insert ContentResolver URI Update Delete
  • 15. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 16. Constructing query SELECT _id, title, content, date FROM articles WHERE date >= 1352470000 ORDER BY date ASC
  • 17. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 18. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 19. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 20. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 21. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 22. Constructing query String[] mProjection = { "_id", "title", "content", "date", }; String mSelection = "date >= ?"; String[] mSelectionArgs = {"1352470000"}; String mSortOrder = "date ASC"; Cursor cursor = getContentResolver().query( MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 23. Cursor _id title content date 1 First article Lorem ipsum... 1352475013 2 Second article Dolor sit amet... 1352471413 ... ... ... ... if (mCursor != null) { while (mCursor.moveToNext()) { String title = mCursor.getString(Columns.TITLE); } }
  • 24. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 25. Activity & blocking queries Activity Cursor ContentResolver Content Provider CursorAdapter ListView
  • 26. Activity & non blocking queries Activity CursorLoader Cursor ContentResolver Content Provider AsyncQueryHandler CursorAdapter ListView
  • 27. Activity & Loader Activity CursorLoader Cursor ContentResolver Content Provider AsyncQueryHandler CursorAdapter ListView
  • 28. Activity & Loader public class ArticlesActivity extends FragmentActivity implements LoaderCallbacks<Cursor> { ... getSupportLoaderManager().initLoader(0, null, this); ... public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader( this, // context MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder); } public void onLoadFinished( Loader<Cursor> loader, Cursor cursor) { mAdapter.swapCursor(cursor); }
  • 29. Activity & Loader public class ArticlesActivity extends FragmentActivity implements LoaderCallbacks<Cursor> { ... getSupportLoaderManager().initLoader(0, null, this); ... public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader( this, // context MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder); } public void onLoadFinished( Loader<Cursor> loader, Cursor cursor) { mAdapter.swapCursor(cursor); }
  • 30. Activity & Loader public class ArticlesActivity extends FragmentActivity implements LoaderCallbacks<Cursor> { ... getSupportLoaderManager().initLoader(0, null, this); ... public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader( this, // context MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder); } public void onLoadFinished( Loader<Cursor> loader, Cursor cursor) { mAdapter.swapCursor(cursor); }
  • 31. Activity & Loader public class ArticlesActivity extends FragmentActivity implements LoaderCallbacks<Cursor> { ... getSupportLoaderManager().initLoader(0, null, this); ... public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader( this, // context MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder); } public void onLoadFinished( Loader<Cursor> loader, Cursor cursor) { mAdapter.swapCursor(cursor); }
  • 32. Activity & Loader public class ArticlesActivity extends FragmentActivity implements LoaderCallbacks<Cursor> { ... getSupportLoaderManager().initLoader(0, null, this); ... public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader( this, // context MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder); } public void onLoadFinished( Loader<Cursor> loader, Cursor cursor) { mAdapter.swapCursor(cursor); }
  • 33. Activity & AsyncQueryHandler Activity CursorLoader Cursor ContentResolver Content Provider AsyncQueryHandler CursorAdapter ListView
  • 34. Activity & AsyncQueryHandler private AsyncQueryHandler mHandler; ... mHandler = new MyAsyncQueryHandler(getContentResolver()); mHandler.startQuery( 0, // token null, // cookie MyContentProvider.ARTICLES_CONTENT_URI, mProjection, mSelection, mSelectionArgs, mSortOrder);
  • 35. Activity & AsyncQueryHandler class MyAsyncQueryHandler extends AsyncQueryHandler { public MyAsyncQueryHandler(ContentResolver cr) { super(cr); } @Override protected void onQueryComplete( int token, Object cookie, Cursor cursor) { mAdapter.swapCursor(cursor); } }
  • 36. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 37. Permissions <permission android:name="com.example.provider.permission.READ_ARTICLES" android:protectionLevel="normal" /> <provider android:name=".MyContentProvider" android:exported="false" android:authorities="com.example.provider" android:permission="com.example.provider.permission.READ_ARTICLES" /> <uses-permission android:name="com.example.provider.permission.READ_ARTICLES" />
  • 38. Permissions <permission android:name="com.example.provider.permission.READ_ARTICLES" android:protectionLevel="normal" /> <provider android:name=".MyContentProvider" android:exported="false" android:authorities="com.example.provider" android:permission="com.example.provider.permission.READ_ARTICLES" /> <uses-permission android:name="com.example.provider.permission.READ_ARTICLES" />
  • 39. Permissions <permission android:name="com.example.provider.permission.READ_ARTICLES" android:protectionLevel="normal" /> <provider android:name=".MyContentProvider" android:exported="false" android:authorities="com.example.provider" android:permission="com.example.provider.permission.READ_ARTICLES" /> <uses-permission android:name="com.example.provider.permission.READ_ARTICLES" />
  • 40. Overall structure ● Interaction with Content Provider ● Constructing query ● Retreiving cursor asyncronuously ● Provider permissions ● Creating Content Provider ● Questions
  • 41. Creating content provider public class MyContentProvider extends ContentProvider { ... onCreate() query() insert() update() delete() getType()
  • 45. URI matching sUriMatcher.addURI("com.example.provider", "articles/#", 0); sUriMatcher.addURI("com.example.provider", "articles/today", 1); sUriMatcher.addURI("com.example.provider", "articles/history/*", 2); ... public String getType(Uri uri) { switch (sUriMatcher.match(uri)) { ...
  • 46. URI matching sUriMatcher.addURI("com.example.provider", "articles/#", 0); sUriMatcher.addURI("com.example.provider", "articles/today", 1); sUriMatcher.addURI("com.example.provider", "articles/history/*", 2); ... public String getType(Uri uri) { switch (sUriMatcher.match(uri)) { ...
  • 51. About speaker Alexey Ustenko — Android developer Coordniator of GDG Dnipropetrovs'k @ustav