I'm a newbie to android programming and have been trying to add events to google calendar via an android application. I found a nice example on the web but cannot seem to get the code to run as the application crashes as soon as the emulator launches. I'm emulating the code on the ANDROID DEVICE (Google APIs/API LEVEL 14).Below is the URL of the code;
http://roman10.net/src/calendarops.zip
Here are the errors which I receive in the logcat;
12-21 15:24:16.602: D/AndroidRuntime(675): Shutting down VM
12-21 15:24:16.612: W/dalvikvm(675): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-21 15:24:16.622: E/AndroidRuntime(675): FATAL EXCEPTION: main
12-21 15:24:16.622: E/AndroidRuntime(675): java.lang.RuntimeException: Unable to start activity ComponentInfo{roman10.tutorial.calendarops/roman10.tutorial.calendarops.Main}: android.database.sqlite.SQLiteException: no such column: displayName: , while compiling: SELECT _id, displayName FROM Calendars
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.os.Handler.dispatchMessage(Handler.java:99)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.os.Looper.loop(Looper.java:137)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-21 15:24:16.622: E/AndroidRuntime(675): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:24:16.622: E/AndroidRuntime(675): at java.lang.reflect.Method.invoke(Method.java:511)
12-21 15:24:16.622: E/AndroidRuntime(675): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-21 15:24:16.622: E/AndroidRuntime(675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-21 15:24:16.622: E/AndroidRuntime(675): at dalvik.system.NativeStart.main(Native Method)
12-21 15:24:16.622: E/AndroidRuntime(675): Caused by: android.database.sqlite.SQLiteException: no such column: displayName: , while compiling: SELECT _id, displayName FROM Calendars
12-21 15:24:16.622: E/AndroidRuntime(675): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.content.ContentResolver.query(ContentResolver.java:310)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Activity.managedQuery(Activity.java:1706)
12-21 15:24:16.622: E/AndroidRuntime(675): at roman10.tutorial.calendarops.Main.getCalendars(Main.java:127)
12-21 15:24:16.622: E/AndroidRuntime(675): at roman10.tutorial.calendarops.Main.onCreate(Main.java:50)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Activity.performCreate(Activity.java:4465)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-21 15:24:16.622: E/AndroidRuntime(675): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-21 15:24:16.622: E/AndroidRuntime(675): ... 11 more
Here it is:
android.database.sqlite.SQLiteException: no such column: displayName:
, while compiling: SELECT _id, displayName FROM Calendars
There is no column with the name 'displayName' in your Calendars table.
Since you are using ICS (SDK 14) they have changed the way they handle Calanders and have made a public API. See http://android-developers.blogspot.com/2011/10/ics-and-non-public-apis.html
Related
i'm trying to instantiate a Dialog in my Activity.
public void createOptionsMenu() {
Log.e("ActivityContext null?","" + myActivity.this);
myOptionsDialog = new Dialog(myActivity.this); //throwsNPE
myOptionsDialog.setContentView(R.layout.options_dialog);
myOptionsDialog.show();
}
Due to the Log.e which you can see above i know that my activity-context is not null!
12-21 15:17:15.466: E/ActivityContext null?(3774): com.android.myproject.myActivity#41fd9af0
12-21 15:17:15.469: E/AndroidRuntime(3774): java.lang.NullPointerException
I think to Problem is that i call createOptionsMenu() from a different class which only has the ApplicationContext from myActivity. If so, how can i create my Dialog without passing the ActivityContext to the other class which calls createOptionsMenu.
Any help is appreciated.
Update:
12-21 15:17:15.469: E/AndroidRuntime(3774): FATAL EXCEPTION: main
12-21 15:17:15.469: E/AndroidRuntime(3774): java.lang.NullPointerException
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:140)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:103)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.app.Dialog.<init>(Dialog.java:154)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.app.Dialog.<init>(Dialog.java:131)
12-21 15:17:15.469: E/AndroidRuntime(3774): at com.android.myproject.myActivity.createOptionsMenu(myActivity.java:798)
12-21 15:17:15.469: E/AndroidRuntime(3774): at com.android.myproject.WorkerClass$2.onItemLongClick(WorkerClass.java:448)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.widget.AbsListView.performLongPress(AbsListView.java:2883)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:2833)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.os.Handler.handleCallback(Handler.java:725)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.os.Handler.dispatchMessage(Handler.java:92)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.os.Looper.loop(Looper.java:153)
12-21 15:17:15.469: E/AndroidRuntime(3774): at android.app.ActivityThread.main(ActivityThread.java:5338)
12-21 15:17:15.469: E/AndroidRuntime(3774): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:17:15.469: E/AndroidRuntime(3774): at java.lang.reflect.Method.invoke(Method.java:511)
12-21 15:17:15.469: E/AndroidRuntime(3774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
12-21 15:17:15.469: E/AndroidRuntime(3774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
12-21 15:17:15.469: E/AndroidRuntime(3774): at dalvik.system.NativeStart.main(Native Method)
Instantiate Activity:
myActivity myActivity_ = new myActivity();
WeakReference<myActivity> myWeakActivity = new WeakReference<myActivity>(myActivity_);
myWeakActivity.get().createOptionsMenu();
The Problem was the Context. As i created a new Object of my Activity the old Activity isn't valid "inside" the new Object.
The soltuion was to simply pass the Activity-Context to createOptionsMenu and then do this:
MyActivity myActivity_ = (MyActivity) context;
Then you have a reference to the resources you really want.
Hope it helps somebody.
This question already has answers here:
Google Play Services update
(6 answers)
Closed 3 years ago.
12-21 02:04:02.430: E/AndroidRuntime(1690): FATAL EXCEPTION: main
12-21 02:04:02.430: E/AndroidRuntime(1690): Process: com.example.main, PID: 1690
12-21 02:04:02.430: E/AndroidRuntime(1690): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.main/com.example.main.ShowRouteMap}: android.view.InflateException: Binary XML file line #66: Error inflating class fragment
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.os.Handler.dispatchMessage(Handler.java:102)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.os.Looper.loop(Looper.java:137)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-21 02:04:02.430: E/AndroidRuntime(1690): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 02:04:02.430: E/AndroidRuntime(1690): at java.lang.reflect.Method.invoke(Method.java:515)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-21 02:04:02.430: E/AndroidRuntime(1690): at dalvik.system.NativeStart.main(Native Method)
12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: android.view.InflateException: Binary XML file line #66: Error inflating class fragment
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.Activity.setContentView(Activity.java:1928)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.example.main.ShowRouteMap.onCreate(ShowRouteMap.java:19)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.Activity.performCreate(Activity.java:5243)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-21 02:04:02.430: E/AndroidRuntime(1690): ... 11 more
12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-21 02:04:02.430: E/AndroidRuntime(1690): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-21 02:04:02.430: E/AndroidRuntime(1690): ... 21 more
you can see your log line
12-21 02:04:02.430: E/AndroidRuntime(1690): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Solution
just put this in your AndroidManifist.xml under application tag
<meta-data
android:name="com.google.android.gms.version"
android:value="4030500" />
My Bluetooth application's can already auto request to enable bluetooth but when I did some functionality on my option menu the application will crash right after the bluetooth was turned on.
These were the messages found in the LogCat:
12-21 15:20:08.531: D/BluetoothCommandService(1203): start
12-21 15:20:08.531: D/BluetoothCommandService(1203): setState() 0 -> 1
12-21 15:20:08.581: W/dalvikvm(1203): threadid=1: thread exiting with uncaught exception (group=0x40028870)
12-21 15:20:08.851: E/AndroidRuntime(1203): FATAL EXCEPTION: main
12-21 15:20:08.851: E/AndroidRuntime(1203): java.lang.NullPointerException
12-21 15:20:08.851: E/AndroidRuntime(1203): at com.example.javac101.MainActivity$1.handleMessage(MainActivity.java:171)
12-21 15:20:08.851: E/AndroidRuntime(1203): at android.os.Handler.dispatchMessage(Handler.java:95)
12-21 15:20:08.851: E/AndroidRuntime(1203): at android.os.Looper.loop(Looper.java:123)
12-21 15:20:08.851: E/AndroidRuntime(1203): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-21 15:20:08.851: E/AndroidRuntime(1203): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:20:08.851: E/AndroidRuntime(1203): at java.lang.reflect.Method.invoke(Method.java:521)
12-21 15:20:08.851: E/AndroidRuntime(1203): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-21 15:20:08.851: E/AndroidRuntime(1203): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-21 15:20:08.851: E/AndroidRuntime(1203): at dalvik.system.NativeStart.main(Native Method)
What would be the possible main cause of this errors?
title might be null here.
Also change
title.setText(R.string.title_notConnected);
to
title.setText(getString(R.string.title_notConnected));
I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}
I have an application of which i have use database to insert values on list view . When I run the app on emulator after merging it runs fine but crashes on the device when values begin inserted the LogCat shows me the:close cursor but i have already close all coursers that begin opened.
this the button action
plus.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
tx = txt.getText().toString();
postive.add(tx);
if(tx.length() >0)
{
myDB.execSQL("INSERT INTO UP (ID,UPNAME) VALUES ('"+idnum+"','"+tx+"')");
txt.setText("");
function();
results.clear();
Intent i=new Intent(Positive.this,NewgridActivity.class);
bundle.putInt("tabid", 1);
bundle.putInt("id", idnum);
i.putExtras(bundle);
startActivity(i);
finish();
}
else
DisplayToast("TextField Empty !!!!");
}
});
any help please.
error in logcat
12-21 13:11:02.582: E/Database(4909): close() was never explicitly called on database '/data/data/pa.gd/databases/DECISION_GRID'
12-21 13:11:02.582: E/Database(4909): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
12-21 13:11:02.582: E/Database(4909): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1810)
12-21 13:11:02.582: E/Database(4909): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817)
12-21 13:11:02.582: E/Database(4909): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851)
12-21 13:11:02.582: E/Database(4909): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844)
12-21 13:11:02.582: E/Database(4909): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540)
12-21 13:11:02.582: E/Database(4909): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
12-21 13:11:02.582: E/Database(4909): at pa.gd.PAIDGRIDActivity.onCreate(PAIDGRIDActivity.java:66)
12-21 13:11:02.582: E/Database(4909): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-21 13:11:02.582: E/Database(4909): at dalvik.system.NativeStart.main(Native Method)
log error afer closing database
i have close the db when i then try to add i a value it crashes with this log error
12-21 15:45:58.043: E/AndroidRuntime(401): FATAL EXCEPTION: main
12-21 15:45:58.043: E/AndroidRuntime(401): java.lang.IllegalStateException: database not open
12-21 15:45:58.043: E/AndroidRuntime(401): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1723)
12-21 15:45:58.043: E/AndroidRuntime(401): at dc.grd.Positive$1.onClick(Positive.java:77)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.view.View.performClick(View.java:2408)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.view.View$PerformClick.run(View.java:8816)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.os.Handler.handleCallback(Handler.java:587)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.os.Handler.dispatchMessage(Handler.java:92)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.os.Looper.loop(Looper.java:123)
12-21 15:45:58.043: E/AndroidRuntime(401): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-21 15:45:58.043: E/AndroidRuntime(401): at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:45:58.043: E/AndroidRuntime(401): at java.lang.reflect.Method.invoke(Method.java:521)
12-21 15:45:58.043: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-21 15:45:58.043: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-21 15:45:58.043: E/AndroidRuntime(401): at dalvik.system.NativeStart.main(Native Method)
Think about a life cycle for you database connection. I recommend to open the db in your application class or in the onResume() method of your activity. Close the db in onPause().
Whenever you work with the database, make sure that all cursors are correctly closed after you are done working with it.
And by the way: Every time you write a question title like you did, a kitten dies...
You seem to be using myDB for your database object. In that case use this to close it: myDB.close();. – Sander van't Veer
<
myDB.close(); the solution give by Sander Vant Veer worked