Problem with the sqlite database

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Problem with the sqlite database

Postby bharath » Mon Nov 24, 2008 3:13 pm

Hi AndroidDev,
11-24 19:27:38.287: ERROR/Database(5891): Leak found
11-24 19:27:38.287: ERROR/Database(5891): java.lang.IllegalStateException: /data/data/com.vista.examples.List/databases/ev_data SQLiteDatabase created and never closed

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() {
SQLiteDatabase vDB=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.
bharath
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Sep 27, 2008 11:21 am

Top

Re:

Postby bharath » Wed Nov 26, 2008 1:04 pm

Hi AndroidDev,
Please let me know whether i can use SQLiteDatabase.openDatabase(getDatabasePath(EVENT_DATA).toString(), null,SQLiteDatabase.OPEN_READONLY ); to get the reference to the database

Is this is the correct way to get reference to database?

Please help guys its urgent.............................

Regards
Bharat.
bharath
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Sep 27, 2008 11:21 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests