Skip to content

@BindContentProvider

xcesco edited this page Apr 6, 2018 · 2 revisions

Given a data-source definition, this annotation allows generating the associated content provider. Basically, this annotation simply specifies the authority to put into manifest.xml file.

Attributes

  • authority: define the AUTHORITY for the content provider.

Usage

Given an example datasource definition:

@BindContentProvider(authority = "com.abubusoft.contentprovidersample.provider")
@BindDataSourceOptions(updateTasks = { @BindDataSourceUpdateTask(version = 1, task = SampleUpdate02.class) }, populator = SamplePopulator.class)
@BindDataSource(daoSet = { CheeseDao.class }, fileName = "sample.db", version = 1)
public interface SampleDataSource {

}

Kripton generates the data-source implementation and the associated content provider. For the SampleDataSource, the content provider generated has name BindSampleContentProvider. Into manifest.xml you need to define the content provider:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.MyApplication">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
         <activity android:name=".MainActivity">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
         </activity>
        
      <provider android:name="PersonProvider"
         android:authorities="com.example.MyApplication.BindSampleContentProvider"/>
   </application>
</manifest>

The generated content provider is generated with Javadoc, feel free to inspect generated source Javadoc to see managed URL and many other features of the generated content provider.

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally