In order to play nicely with the resources you share with other
applications I think you might want to consider creating your
connection in onCreate, and cleaning it up in onPause.  You mentioned
an issue when you tried that earlier but it might be worth resolving
within your app.  This will keep your connection open to the database
for only the amount of time when your application is actually being
viewed (i think).

http://code.google.com/android/reference/android/app/Activity.html

On Dec 13, 5:02 pm, thisnameagain <micah...@gmail.com> wrote:
> I cleared up my problem with the SQL not closing and creating a leak
> by make sure to close the connection in onDestroy. I had tried to
> close the connection earlier, but that caused a different problem.
> When I close it in onDestroy everything works well. Hope that might
> help someone.
>
> On Dec 13, 5:47 pm, thisnameagain <micah...@gmail.com> wrote:
>
> > Wondering if you ever solved this? I am getting a similar problem and
> > I have notfoundanything that works, or others solutions.
>
> > On Nov 26, 10:30 pm, "bharath kumar" <bhrthkum...@gmail.com> wrote:
>
> > > Hi AndroidDev,
> > > 11-24 19:27:38.287: ERROR/Database(5891):Leakfound
> > > 11-24 19:27:38.287: ERROR/Database(5891): java.lang.IllegalStateException:
> > > /data/data/com.vista.examples.List/databases/ev_dataSQLiteDatabasecreated
> > > andneverclosed
>
> > > i got the above error .how to resolve the problem.?
>
> > > Also ,please check my code below to create the database and accessign the
> > > database.
>
> > > [/code]public void onCreate(Bundle icicle) {
> > > super.onCreate(icicle);
> > > initDB(this);
> > > //mOpenHelper=new DatabaseHelper(this);
> > > itla = new IconifiedTextListAdapter(this);
> > > showEventList();}
>
> > > public void initDB(Context ctx) {
> > > db = ctx.openOrCreateDatabase(EVENT_DATA,
> > > Context.MODE_WORLD_WRITEABLE,null);
> > > db.execSQL("CREATE TABLE IF NOT EXISTS " + EVENT_DATA
> > > + " (EventType VARCHAR,Description VARCHAR, Image INTEGER,Msg_Template
> > > TEXT);");
>
> > > }
>
> > > public void showEventList() {
> > >SQLiteDatabasevDB=null;
> > > try{
> > > vDB=SQLiteDatabase.openDatabase(getDatabasePath(EVENT_DATA).toString(),
> > > null,SQLiteDatabase.OPEN_READONLY ); }catch(SQLiteException sqe){
> > > sqe.printStackTrace();}
>
> > > Cursor cursor=vDB.query(EVENT_DATA, new
> > > String[]{"EventType,Image,Description"}, null, null, null, null, null);
> > > cursor.moveToFirst();
> > > for(int position=0;(position!=cursor.getCount())&&
> > > cursor.getCount()!=0;position++){
> > > String text=cursor.getString(0);
> > > int im=cursor.getInt(1);
> > > itla.addItem(new IconifiedText(text, getResources().getDrawable(im)));
> > > cursor.moveToNext();}
>
> > > setListAdapter(itla);
> > > [code]
>
> > > I am using getDatabasePath to connect to db
> > > Is this is the proper way to create as well as accessing the database?
>
> > > Please suggest...
>
> > > Regards
> > > Bharat.
--~--~---------~--~----~------------~-------~--~----~
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