sirmmo / android-classcontentprovider Goto Github PK
View Code? Open in Web Editor NEWReflection based ContentProvider implementation for a simpler development of datadriven apps
Reflection based ContentProvider implementation for a simpler development of datadriven apps
Usage: - import the JAR file of the application - Create class that extends ClassContentProvider - Prepare your model -- Annotate the classes with both @Table and @Authority -- Annotate the fields with @Column and the primarykey fields with @PrimaryKey. If the field is integer and primarykey you can add @Autoincrement. - in constructor invoke provideClass for every type of resource you want to expose with the provider. And it should be done! :)
I'm getting a Null Pointer Exception when trying to create a Content Provider.
Logcat:
08-02 11:46:08.191: E/AndroidRuntime(10855): FATAL EXCEPTION: main
08-02 11:46:08.191: E/AndroidRuntime(10855): java.lang.RuntimeException: Unable to get provider com.atami.ics.provider.NodeIndexProvider: java.lang.NullPointerException
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.installProvider(ActivityThread.java:4563)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.os.Looper.loop(Looper.java:137)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-02 11:46:08.191: E/AndroidRuntime(10855): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 11:46:08.191: E/AndroidRuntime(10855): at java.lang.reflect.Method.invoke(Method.java:511)
08-02 11:46:08.191: E/AndroidRuntime(10855): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-02 11:46:08.191: E/AndroidRuntime(10855): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-02 11:46:08.191: E/AndroidRuntime(10855): at dalvik.system.NativeStart.main(Native Method)
08-02 11:46:08.191: E/AndroidRuntime(10855): Caused by: java.lang.NullPointerException
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.model.ColumnModel.fk_declaration(ColumnModel.java:99)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.model.ColumnModel.toSQL(ColumnModel.java:33)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.model.TableModel.toSQL(TableModel.java:23)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.ClassContentProvider.getCreationString(ClassContentProvider.java:103)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.ClassContentProvider.access$0(ClassContentProvider.java:100)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.ClassContentProvider$DBHelper.onCreate(ClassContentProvider.java:206)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
08-02 11:46:08.191: E/AndroidRuntime(10855): at it.mmo.classcontentprovider.ClassContentProvider.onCreate(ClassContentProvider.java:122)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.content.ContentProvider.attachInfo(ContentProvider.java:1058)
08-02 11:46:08.191: E/AndroidRuntime(10855): at android.app.ActivityThread.installProvider(ActivityThread.java:4560)
08-02 11:46:08.191: E/AndroidRuntime(10855): ... 12 more
Content Provider:
https://gist.github.com/3238104
NodeIndex.java
When I added the ccp.jar to my build path, the @column annotation could not be found. When I exported the source packages to a jar, however, the annotation was able to be imported.
Fantastic library my friend.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.