tags:

views:

37

answers:

1

Hi I am using the sqlite in my app.when i am geting the values form db i am getting below error .Please tell me when this type of errors are coming and suggest me for this one.

10-30 15:06:07.584: ERROR/Database(817): Leak found
10-30 15:06:07.584: ERROR/Database(817): java.lang.IllegalStateException: /data/data/com.fitzsoftware.grocessaryList/databases/example.db SQLiteDatabase created and never closed
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1581)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:659)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:652)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:482)
10-30 15:06:07.584: ERROR/Database(817):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
10-30 15:06:07.584: ERROR/Database(817):     at com.fitzsoftware.grocessaryList.DataHelper.<init>(DataHelper.java:46)
10-30 15:06:07.584: ERROR/Database(817):     at com.fitzsoftware.grocessaryList.MyShoppingList.onCreate(MyShoppingList.java:63)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
10-30 15:06:07.584: ERROR/Database(817):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-30 15:06:07.584: ERROR/Database(817):     at android.os.Looper.loop(Looper.java:123)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.main(ActivityThread.java:4203)
10-30 15:06:07.584: ERROR/Database(817):     at java.lang.reflect.Method.invokeNative(Native Method)
10-30 15:06:07.584: ERROR/Database(817):     at java.lang.reflect.Method.invoke(Method.java:521)
10-30 15:06:07.584: ERROR/Database(817):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-30 15:06:07.584: ERROR/Database(817):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
10-30 15:06:07.584: ERROR/Database(817):     at dalvik.system.NativeStart.main(Native Method)

because of this error data which is coming from db takes so much time to display

A: 

Looks like you open the database but never close it...? Or maybe a corrupt database file...? Try uninstalling your program and run it again. Do you get the same error the first time you run it? - or the second time?

Espen
second tome onwards i am getting the error
sairamu
I would guess that the first time you run it the program opens/creates the database. Then you forget to close it properly and then the second time your program cannot get access to it - becasue it is open. I havent worked to much with sqlite to be more precise. I would say you have to do it step by step. Creating a new program and starting with nothing but creating and closing a database and adding stuff from there noticing when it goes wrong.
Espen
where i am closing the database ,By using onCreate(SQLiteDatabase db) method I am crating the db ,How i am close the db (which method)
sairamu
You will probably have to do something like db.close() when you're finished with it. I'm not completely sure as to sqlite but a quick search for "sqlite android tutorial" gave some results, and one of them where: http://www.anddev.org/working_with_the_sqlite-database_-_cursors-t319.html - I'm sure you'll see how to completely use a simple database there.
Espen