GetWritableDatabase generates a nullPointerException

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

GetWritableDatabase generates a nullPointerException

Postby immanueln2005 » Thu Jan 22, 2009 6:55 am

Hi,

I'm using a class, say TEMP which extends activity to access a already created database. This activity doesn't have anything to do with UI. I am using TEMP only to insert and update records in a database.

From this class, i.e TEMP, i try to access the database helper of the database class.

There is no error when i pass an instance of TEMP.

This is the code called on opening the databasehelper at TEMP.

public SwapCard_mob open() throws SQLException
{
mDbHelper = new DatabaseHelper(mCtx);
mDb = mDbHelper.getWritableDatabase();
return this;
}

mDbHelper = new DatabaseHelper(mCtx); does not generate any error.

mDb = mDbHelper.getWritableDatabase(); raises a nullPointerException.

Here is the log.
---------------------------------------

01-22 11:10:21.241: ERROR/XML PARSER(405): XML PARSER
01-22 11:10:21.241: ERROR/XML PARSER(405): java.lang.NullPointerException
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:181)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.SwapCard_mob.open(SwapCard_mob.java:149)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.parserdata.setContact(parserdata.java:92)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.ExampleHandler.startElement(ExampleHandler.java:133)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:145)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatParser.append(Native Method)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:506)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
01-22 11:10:21.241: ERROR/XML PARSER(405): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.SwapCard.Login(SwapCard.java:186)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.SwapCard.Authentication(SwapCard.java:125)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.SwapCard.access$0(SwapCard.java:99)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.SwapCard.UI.SwapCard$2.onClick(SwapCard.java:95)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.View.performClick(View.java:2109)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.View.onTouchEvent(View.java:3523)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.widget.TextView.onTouchEvent(TextView.java:4410)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.View.dispatchTouchEvent(View.java:3178)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:857)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1561)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1085)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.app.Activity.dispatchTouchEvent(Activity.java:1873)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1545)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.view.ViewRoot.handleMessage(ViewRoot.java:1140)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.os.Handler.dispatchMessage(Handler.java:88)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.os.Looper.loop(Looper.java:123)
01-22 11:10:21.241: ERROR/XML PARSER(405): at android.app.ActivityThread.main(ActivityThread.java:3742)
01-22 11:10:21.241: ERROR/XML PARSER(405): at java.lang.reflect.Method.invokeNative(Native Method)
01-22 11:10:21.241: ERROR/XML PARSER(405): at java.lang.reflect.Method.invoke(Method.java:515)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
01-22 11:10:21.241: ERROR/XML PARSER(405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
01-22 11:10:21.241: ERROR/XML PARSER(405): at dalvik.system.NativeStart.main(Native Method)

-----------------------------------

Hope to find a solution to this soon.

Thanks,
Immanuel
immanueln2005
Developer
Developer
 
Posts: 42
Joined: Tue Dec 30, 2008 1:25 pm
Location: INDIA

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests