sirmmo / Android-ClassContentProvider

Reflection based ContentProvider implementation for a simpler development of datadriven apps
2 stars 0 forks source link

NullPointerException when creating Content Provider #2

Open SeanPONeil opened 12 years ago

SeanPONeil commented 12 years ago

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

https://gist.github.com/3238111

sirmmo commented 12 years ago

Hi! Thanks for using my library! :)

I didn't maintain the code very much in the last year: I'm going to fix the bugs and improve the functionalities in the next three weeks, but if you want to push some fixes, you are very welcome! I saw you deleted the ForeignKey part, which after some time I see is a good thing (and it keeps the library more or less working): if you need FKs you probably shouldn't be saving them on a phone.

SeanPONeil commented 12 years ago

That was what I was thinking too with the foreign keys. Most Content Providers contain just a few tables, if not just one table. Adding foreign keys could be interesting, but in the average case unnecessary.

Thanks for starting this library, it was EXACTLY what I was looking for! :)