HistoryProvider
History Provider is a simple library that stores your typed history inside a Database using the concept of Content providers, making the history database available to any application in the phone.
Installation
Add gradle dependency with command:
dependencies {
compile 'org.ishmeetsingh.androbot:historyprovider:1.0.0'
}
By using Maven:
<dependency>
<groupId>org.ishmeetsingh.androbot</groupId>
<artifactId>historyprovider</artifactId>
<version>1.0.0</version>
<type>pom</type> </dependency>
Implementation
These steps are required to implement HistoryProvider in your Android Project:
- Make a new class and
implements
Cursor Loaderandroid.app.LoaderManager.LoaderCallbacks<Cursor>
and Override all the methods. - Make an
Listview
and make an Adapter for it. - In the MainActivity, Define an EditText by
findViewById()
and make a method to store words in the Database like this:
String name = EditText_Name.getText().toString().trim();
ContentValues values = new ContentValues();
values.put(WordContract.WordEntry.COLUMN_WORD_NAME,name);
Uri newUri = getContentResolver().insert(WordContract.WordEntry.CONTENT_URI, values);
FULL IMPLEMENTATION FOR ABOVE STEPS IS PROVIDED IN THE SAMPLE APP.
Additional Important Requirement:
Define the Content Provider in the Manifest file like this(No Values should be changed here excluding the provider name):
<provider android:name="com.example.historyprovider_library.WordsProvider" android:authorities="com.example.android.words" android:enabled="true" android:exported="true" android:multiprocess="true" />