[mono-android] SqliteOpenHelper blowing up
Michael Isbell
michael.isbell at gmail.com
Sun Mar 20 01:54:32 EDT 2011
// in my starting actiivty i do this
Application context = this.Application;
RestaurantHelper helper=new RestaurantHelper(context); /// a
SqliteOpenHelper
// and it blows up here
public class RestaurantHelper : SQLiteOpenHelper
{
private const string DATABASE_NAME = "lunchlist";
private const int DATABASE_VERSION = 1;
public RestaurantHelper(Android.Content.Context context)
: base(context, DATABASE_NAME, null, DATABASE_VERSION)
{
// its blowing up in this method
}
// and I get this error
I/MonoDroid( 1343): UNHANDLED EXCEPTION: System.NullReferenceException:
Object reference not set to an instance of an object
I/MonoDroid( 1343): at MonoDroid.Utils.JniType.ToJniName<System.Type>
(System.Type,System.Func`2<System.Type,
System.Type>,System.Func`2<System.Type, string>,System.Func`2<System.Type,
string>) <0x0014c>
I/MonoDroid( 1343): at MonoDroid.Utils.JniType.ToJniName (System.Type)
<0x0020f>
I/MonoDroid( 1343): at Android.Runtime.JNIEnv.FindClass (System.Type)
<0x00027>
I/MonoDroid( 1343): at Android.Database.Sqlite.SQLiteOpenHelper..ctor
(Android.Content.Context,string,Android.Database.Sqlite.SQLiteDatabase/ICursorFactory,int)
<0x0007b>
I/MonoDroid( 1343): at RestaurantHelper..ctor (Android.Content.Context)
<0x0003b>
I/MonoDroid( 1343): at murphytutorial1.LunchList.OnCreate
(Android.OS.Bundle) <0x00073>
I/MonoDroid( 1343): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_
(intptr,intptr,intptr) <0x0005f>
I/MonoDroid( 1343): at (wrapper dynamic-method)
object.81033dba-ac10-4c4a-8fb9-adf95e502d00 (intptr,intptr,intptr) <0x00033>
E/mono ( 1343):
E/mono ( 1343): Unhandled Exception: System.NullReferenceException:
Object reference not set to an instance of an object
E/mono ( 1343): at MonoDroid.Utils.JniType.ToJniName[Type] (System.Type
type, System.Func`2 decl, System.Func`2 name, System.Func`2 ns) [0x00000] in
<filename unknown>:0
E/mono ( 1343): at MonoDroid.Utils.JniType.ToJniName (System.Type type)
[0x00000] in <filename unknown>:0
E/mono ( 1343): at Android.Runtime.JNIEnv.FindClass (System.Type type)
[0x00000] in <filename unknown>:0
E/mono ( 1343): at Android.Database.Sqlite.SQLiteOpenHelper..ctor
(Android.Content.Context context, System.String name, ICursorFactory
factory, Int32 version) [0x00000] in <filename unknown>:0
E/mono ( 1343): at RestaurantHelper..ctor (Android.Content.Context
context) [0x00000] in <filename unknown>:0
E/mono ( 1343): at murphytutorial1.LunchList.OnCreate
(Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
E/mono ( 1343): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_
(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState)
[0x00000] in <filename unknown>:0
E/mono ( 1343): at (wrapper dynamic-method) obj
-----
context is not null when he ctor is run, it contains a pointer to an
Application
jonathan, if you're checking this out it's app 11 in my dropbox
FYI I found your and shakles web pages on db access
i am doing three passes on this code
1 straight translation from murphy code
2 your way ADO.NET
3 shakles way with ORM
but first I have to get this to work ... :-)
--
Mike Isbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110320/daeb5893/attachment-0001.html
More information about the Monodroid
mailing list