Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Database getting blank in android
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Abhi  
View profile  
 More options Aug 8 2012, 6:44 am
From: Abhi <abhishekkaus...@intersoftprofessional.com>
Date: Wed, 8 Aug 2012 03:44:20 -0700 (PDT)
Local: Wed, Aug 8 2012 6:44 am
Subject: Database getting blank in android

Hello,

I am developing an app. It is working fine but if i left the app open for
few hours the database gets blank sometimes(1 out of 5). I tried hard to
track the issue but couldn't found any. I am using Sqlite database. Please
help me as soon as possible.

Thanks
Abhi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pedro Cortez  
View profile  
 More options Aug 8 2012, 5:15 pm
From: Pedro Cortez <pedro.fellipe.cor...@gmail.com>
Date: Wed, 8 Aug 2012 18:15:15 -0300
Local: Wed, Aug 8 2012 5:15 pm
Subject: Re: [android-developers] Database getting blank in android

Did you close de SQLiteDatabase db? Sometimes in my app when i didnt close
my db, my app gave me some exception.
I put this funcion on my activities

@Override
protected void onDestroy() {
super.onDestroy();
dao.cleanup();

}

public void cleanup() {
       if (this.db != null) {
           this.db.close();
           this.db = null;
       }
 }

I hope i could help u

On Wed, Aug 8, 2012 at 7:44 AM, Abhi <

--
att,
Pedro Cortez

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobu Games  
View profile  
 More options Aug 8 2012, 6:34 pm
From: Nobu Games <dev.nobu.ga...@gmail.com>
Date: Wed, 8 Aug 2012 15:34:40 -0700 (PDT)
Local: Wed, Aug 8 2012 6:34 pm
Subject: Re: Database getting blank in android

Database corruption can also happen when you open the same database file
multiple times simultaneously. When the database is broken SQLiteDatabase
simply re-creates the database file by default. I think that is largely
fixed in newer Android versions and you would get a DatabaseLockedException
if you try to open it multiple times.

Make sure to:

   1. Only use a single SQLiteDatabase connection / SQliteOpenHelper per
   database file
   2. Open / close that connection at appropriate times in your activity
   life cycle.

About 2.:

If you create the connection in onCreate / onResume and close it in onStop
or onDestroy for example it is very likely that you'll end up with two open
SQLiteDatabase connection objects simultaneously because two activities are
likely to intersect in that case. You could probably get around that by
opening the connection object in onResume and closing it in onPause.

Alternatively you can keep your database connection object as a singleton
in your application object for example. Keep a reference counter there too.
Every time when your activity starts it can request the db connection and
increment the reference counter by one. When your activity is done
(onDestroy) it can decrement the counter. If the counter hits zero you can
close the db connection.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Abhi  
View profile  
 More options Aug 10 2012, 8:21 am
From: Abhi <abhishekkaus...@intersoftprofessional.com>
Date: Fri, 10 Aug 2012 05:21:50 -0700 (PDT)
Local: Fri, Aug 10 2012 8:21 am
Subject: Re: [android-developers] Database getting blank in android

Thanks Pedro for your reply.
 I had already put all the checks to open or close the database . The thing
is that this issue is occuring not so often and also it is occuring in
Samsung gi5800 phone. If i intentionally left the app opened for few hours
then it won't come. I just want to confirm that whether this error is in my
code or it is the issue with this phone.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »