├── .classpath ├── .gitignore ├── AndroidManifest.xml ├── LICENSE_LGPL_V2 ├── Makefile ├── README.md ├── example ├── .classpath ├── AndroidManifest.xml ├── lint.xml ├── proguard.cfg ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── layout │ │ ├── detail.xml │ │ ├── dialog_filter.xml │ │ ├── edit.xml │ │ └── main.xml │ ├── menu │ │ ├── item_context.xml │ │ ├── item_edit.xml │ │ └── main.xml │ ├── values │ │ └── strings.xml │ └── xml │ │ └── searchable.xml └── src │ └── edu │ └── mit │ └── mobile │ └── android │ └── content │ └── example │ ├── Message.java │ ├── MessageDetail.java │ ├── MessageEdit.java │ ├── SampleProvider.java │ └── SimpleContentProviderExample.java ├── lint.xml ├── project.properties ├── res └── .gitignore ├── src └── edu │ └── mit │ └── mobile │ └── android │ └── content │ ├── AndroidVersions.java │ ├── ContentItem.java │ ├── ContentItemRegisterable.java │ ├── DBHelper.java │ ├── DBHelperMapper.java │ ├── DBSortOrder.java │ ├── DBTable.java │ ├── ForeignKeyDBHelper.java │ ├── ForeignKeyManager.java │ ├── GenericDBHelper.java │ ├── Manager.java │ ├── OnSaveListener.java │ ├── ProviderUtils.java │ ├── QuerystringWrapper.java │ ├── SQLGenUtils.java │ ├── SQLGenerationException.java │ ├── SimpleContentProvider.java │ ├── UriPath.java │ ├── annotation │ └── SQLExtractor.java │ ├── column │ ├── BlobColumn.java │ ├── BooleanColumn.java │ ├── DBColumn.java │ ├── DBColumnType.java │ ├── DBForeignKeyColumn.java │ ├── DatetimeColumn.java │ ├── DoubleColumn.java │ ├── FloatColumn.java │ ├── IntegerColumn.java │ ├── TextColumn.java │ └── TimestampColumn.java │ ├── dbhelper │ ├── ContentItemDBHelper.java │ └── SearchDBHelper.java │ ├── m2m │ ├── IdenticalChildFinder.java │ ├── M2MColumns.java │ ├── M2MDBHelper.java │ ├── M2MManager.java │ └── M2MReverseHelper.java │ ├── package.html │ └── query │ ├── QueryBuilder.java │ ├── QuerystringParser.java │ └── QuerystringParser.y └── test ├── AndroidManifest.xml ├── project.properties ├── res ├── drawable-hdpi │ └── icon.png ├── drawable-ldpi │ └── icon.png ├── drawable-mdpi │ └── icon.png └── values │ └── strings.xml └── src └── edu └── mit └── mobile └── android └── content └── test ├── ContentResolverTestUtils.java ├── SampleProvider1.java ├── SampleProvider1Test.java ├── SampleProvider2.java ├── SampleProvider2Test.java ├── SampleProvider3.java ├── SampleProvider3Test.java ├── SampleProvider4.java ├── SampleProvider4Test.java ├── query ├── ParserTest.java └── QueryBuilderTest.java ├── sample1 └── Message.java ├── sample2 ├── BlogPost.java └── Comment.java ├── sample3 ├── Person.java └── Project.java ├── sample4 └── Person.java └── sample5 ├── Bookmark.java ├── IdenticalTagFinder.java ├── SampleProvider5.java ├── SampleProvider5Test.java └── Tag.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | gen/ 3 | doc/ 4 | .project 5 | test/.project 6 | test/.classpath 7 | local.properties 8 | build.xml 9 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | yacc=bison 2 | 3 | all: src/edu/mit/mobile/android/content/query/QuerystringParser.java 4 | %.java: %.y 5 | $(yacc) -o $@ $< 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Simple Content Provider 2 | ======================= 3 | 4 | This library aims to make creation of private and public ContentProviders trivial. 5 | 6 | If your app is backed by a database, chances are you took one look at the 7 | [Content Provider API][1] and decided that it wasn't worth the effort to use. This 8 | library aims to help that by removing the need to do all the legwork of writing 9 | all the basic CRUD operations that you'll encounter writing a basic content 10 | provider. 11 | 12 | By using this library, you shouldn't need to write *any* SQL for most 13 | applications — table creation, query generation, etc. are all handled for you. 14 | 15 | This library is loosely inspired by [Django][2] and follows some of its design 16 | principles. It also follows the [REST][8]ful design principles that underly 17 | Android's data-driven activity flow and encourages the use of URIs to represent 18 | all data objects. 19 | 20 | One can think of this library a bit like a super stripped down ORM — similar to 21 | Hibernate or ORMlite. 22 | 23 | Unlike ORMs, this library aims to have very little object creation in order to 24 | minimize garbage collection churn. This follows Android's existing Content 25 | Provider APIs closely, making it so that there should be very little difference 26 | between the use of the content providers created by this library and any other 27 | Content Provider Android already exposes (contacts, media, calendars, etc.). 28 | 29 | Additionally, this library aims to be flexible enough to allow for easy 30 | extension if what it provides is too simple for your application. 31 | 32 | Features 33 | -------- 34 | 35 | * Drastically simplifies the creation of SQLite-backed ContentProviders — Android's core data persistence layer — for most common cases 36 | * Supports basic table/object creation as well as foreign key and m2m relationships 37 | * URI-based automatic query generation makes it easy to pass views of data between activities 38 | * Provides easy integration into Android's global search 39 | * Multi-process, multi-threading access is handled automatically 40 | * Designed to be used alongside other libraries 41 | * ContentProviders made with this library can be exported to other Android apps 42 | 43 | Example 44 | ------- 45 | 46 | For an example / demo of the library, please see the [example code][6] (also 47 | available on [Google Play][10]). The example shows the core features as 48 | well as demonstrates how to hook the library into a UI. 49 | 50 | It's probably best to start at [SampleProvider][4] and eventually make your way 51 | through [Message][5] and the accompanying activities. 52 | 53 | Using 54 | ----- 55 | 56 | The [Javadocs][9] try to be extensive. You should start at 57 | [SimpleContentProvider][3] which includes a brief walk-through of the system. 58 | 59 | 60 | License 61 | ------- 62 | Android Simple Content Provider 63 | Copyright (C) 2011-2013 [MIT Mobile Experience Lab][7] 64 | 65 | This library is free software; you can redistribute it and/or 66 | modify it under the terms of the GNU Lesser General Public 67 | License version 2.1 as published by the Free Software Foundation 68 | 69 | This library is distributed in the hope that it will be useful, 70 | but WITHOUT ANY WARRANTY; without even the implied warranty of 71 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 72 | Lesser General Public License for more details. 73 | 74 | You should have received a copy of the GNU Lesser General Public 75 | License along with this library; if not, write to the Free Software 76 | [gnu.org/licenses/lgpl.html][11] 77 | 78 | [1]: http://developer.android.com/intl/de/guide/topics/providers/content-providers.html 79 | [2]: https://www.djangoproject.com/ 80 | [3]: http://mel-tools.mit.edu/code/SimpleContentProvider/doc/edu/mit/mobile/android/content/SimpleContentProvider.html 81 | [4]: https://github.com/mitmel/SimpleContentProvider/blob/master/example/src/edu/mit/mobile/android/content/example/SampleProvider.java 82 | [5]: https://github.com/mitmel/SimpleContentProvider/blob/master/example/src/edu/mit/mobile/android/content/example/Message.java 83 | [6]: https://github.com/mitmel/SimpleContentProvider/tree/master/example/ 84 | [7]: http://mobile.mit.edu/ 85 | [8]: http://en.wikipedia.org/wiki/Representational_State_Transfer 86 | [9]: http://mel-tools.mit.edu/code/SimpleContentProvider/doc/ 87 | [10]: https://play.google.com/store/apps/details?id=edu.mit.mobile.android.content.example 88 | [11]: http://www.gnu.org/licenses/lgpl.html 89 | -------------------------------------------------------------------------------- /example/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | 14 | 15 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 68 | 69 | 70 | 71 | 72 | 73 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 86 | 87 | 88 | 89 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /example/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /example/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /example/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-16 12 | android.library.reference.1=.. 13 | -------------------------------------------------------------------------------- /example/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmel/SimpleContentProvider/e55f1a8bcf2c31b2431c2a31bcf9f44c599c12b8/example/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmel/SimpleContentProvider/e55f1a8bcf2c31b2431c2a31bcf9f44c599c12b8/example/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /example/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmel/SimpleContentProvider/e55f1a8bcf2c31b2431c2a31bcf9f44c599c12b8/example/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitmel/SimpleContentProvider/e55f1a8bcf2c31b2431c2a31bcf9f44c599c12b8/example/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/res/layout/detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/res/layout/dialog_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/res/layout/edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 16 | 17 | 22 | 23 | 24 | 31 | 32 | 37 | 38 | 39 | 45 | 46 | 47 | 48 | 49 | 50 | 55 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | 73 | 74 | 49 | 50 |