I ran into this problem too, and in my case it wasn't so easy to go
find all of the c.close() calls since I hadn't written any. For the
next person who runs into this, it turns out that
SimpleCursorAdapter.changeCursor() will close the previous cursor (as
documented). So instead of calling changeCursor directly, you have to
first retrieve the previous cursor and stopManaging it. It would be
nice if the second step were explicitly in the documentation too.

I considered avoiding having the cursors managed at all, since the
Adapter takes responsibility for closing the cursors, but I suspect
the automatic .deactivate() and .requery() calls are useful for saving
resources when the Activity isn't in the foreground.

On Feb 23, 5:48 pm, Komal <komal...@gmail.com> wrote:
> Hi,,
> The Problem is solved, I am posting the solution because some body may
> face same problem and need solution.
> In my app i am using startManagingCursor(c) for managing cursor,,so
> the method handles all functions of cursor,,i  doesn’t need to close
> the cursor.
> I have removed all c.close() from my app ,,and now my app is running
> successfully.
>
> Thanx to all for help.
> Cheers
> Komal
>
> On Feb 20, 4:52 am, Sundog <sunns...@gmail.com> wrote:
>
> > You closed your database - probably on the activity exit -  and
> > subsequently tried to access it. Been there, done that! ;)
>
> > On Feb 18, 5:09 pm, Komal <komal...@gmail.com> wrote:
>
> > > Hi,
> > > Thnx for replying.
> > > when i am pressing back button ,it is throwing exception,,
> > > in my Logcat,,
>
> > > Java.lang.RuntimeException:Unable to resume activity {android.myempapp/
> > > android.myempapp.MoreData}: java.lang.IllegalStateException : attempt
> > > to acquire a reference on a closeSQLiteClosable}
>
> > > and on phone it is saying
>
> > >  The application Emp Application (process android.myempapp) has
> > > stopped unexpectedly.Plese try again.
>
> > > I cant understand what it mean to say..
>
> > > thnx
>
> > > On Feb 16, 6:43 pm, Greg Krimer <gkri...@gmail.com> wrote:
>
> > > > Transitioning to a previous activity via the Back hard-key should be
> > > > handled by Android for you (unless you are capturing the Back key
> > > > event yourself, which does not sound like what you are doing because
> > > > onPause() of your second activity is getting called). The only way I
> > > > have screwed this up is when I had errors in my Activity callbacks
> > > > that prevented the activity from running, as mentioned by Sundog. Have
> > > > you checked the logs (adb logcat or DDMS) for any exceptions thrown
> > > > when you transition from your second activity to your first? What
> > > > exactly happens when you hit the Back button from your second
> > > > activity? What do you see on the screen when you press the Back
> > > > button?
>
> > > > On Feb 15, 6:51 pm, Komal <komal...@gmail.com> wrote:
>
> > > > >  Hi,
> > > > > Thnx  for  replying.
> > > > > Its calling onPause() method of second activity but its not calling
> > > > > onResume() of first activity. why it is so??
> > > > > This is my code for calling next activity
>
> > > > > protected void onListItemClick(ListView l, View v, int position, long
> > > > > id) {
> > > > >                 super.onListItemClick(l, v, position, id);
> > > > >                 Intent i = new Intent(this,WebViewData.class);
> > > > >                 //int clickedposition=(mypos-15) + position;
> > > > >                 int clickedposition=(15 * clicks) + position;
>
> > > > >                 i.putExtra("position",clickedposition);
> > > > >                 i.putExtra("tablerequired",tableRequired);
> > > > >                 startActivity(i);
> > > > >             }
>
> > > > > i am not using finish() in my second activity because if i call finish
> > > > > () then its just going in that activity  and coming back in previous
> > > > > activity, not displaying the details of second activity.
>
> > > > > and another thing is,,
>
> > > > > In my onResume() of first activity i am calling on function which
> > > > > displays the employee list using setListAdapter(new IconicAdapter
> > > > > (MoreData.this))..where  i am overriding getView() method.
>
> > > > > as i m just displaying the details of  employees in my second
> > > > > activity, there’s nothing(any field or variable or anything) which is
> > > > > related to previous activity which i can save in onPause() of second
> > > > > activity.
> > > > > what should i write in my onPause() method of second activity.
> > > > > I had a look at Notepadv3 Application of google,,they are saving
> > > > > mRowID and inserting or updating data.i am not doing anything like
> > > > > this,,i m just displaying information..then what should i write in my
> > > > > onPause().
>
> > > > > As i am  new to android, may be i misunderstood some concepts, please
> > > > > help me!!!
> > > > > Thnx in advance,
>
> > > > > On Feb 14, 2:31 am, Sundog <sunns...@gmail.com> wrote:
>
> > > > > > To expand on that, I had exactly this problem and found that my 
> > > > > > first
> > > > > > activity's onResume() was indirectly reinitializing something it
> > > > > > shouldn't have, and kaboom.
>
> > > > > > On Feb 9, 9:05 pm, Komal <komal...@gmail.com> wrote:
>
> > > > > > > Hi,
> > > > > > > I am developing simple application.
> > > > > > > I have one activity which displays list of name of employees. I m
> > > > > > > fetching the employees name from database.
> > > > > > > when i click on any of the name ,i will display the next page 
> > > > > > > showing
> > > > > > > details of that employee. also fetching details of employee from 
> > > > > > > the
> > > > > > > database.
> > > > > > > It is working perfectly.
> > > > > > > but when i press back button of android phone to go back to the
> > > > > > > list ,i m facing an error.
> > > > > > > how can i go back to the list?
> > > > > > > please help me!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to