jeudi 29 octobre 2015

Android : IllegalStateException: Cannot perform this operation because the connection pool has been closed

I'm getting error again and again and application is crash when i come back to previouse page or start the page.Before using any query i initialize this

dbhelper = new MyDbHelper(this);
dbhelper.onOpen(db);

If i comment the code line of db.close or even when i use db.close after cursor closing the error is occurs repeatedly.Can someone tell me how to handle the database .Why this error is come reportedly. Thanks in advanved
Here is my code

public void getDoenLoaddata() {
        SQLiteDatabase db = dbhelper.getWritableDatabase();
        Cursor cursor = db.rawQuery("select * from ActivityObjectList", null);

        if (cursor.moveToFirst()) {
            do {
                imageName = cursor.getString(cursor.getColumnIndex("imageaudioPath"));
                String strDownLoadStatus = cursor.getString(cursor.getColumnIndex("DownLoad_Status"));

                if (strDownLoadStatus.equalsIgnoreCase("0")) {
                    if (imageName.endsWith(mp3_Pattern))
                    {

                        str_DownLoadUrl = namespace + "/DownloadFile/FilePathMobile/ATTACHMENT/FileName/" + imageName;
                        DownLoadAudioFile(str_DownLoadUrl, imageName);
                        strDownLoadStatus = "1";
                        dbhelper.update_DownLoadStatus(imageName, strDownLoadStatus);
                    }
                    if (imageName.endsWith(png_Pattern) || imageName.endsWith(jpg_pattern) || imageName.endsWith(bmp_pattern) || imageName.endsWith(gif_pattern) || imageName.endsWith(jpeg_pattern)) {
                        str_DownLoadUrl = namespace + "/DownloadFile/FilePathMobile/ATTACHMENT/FileName/" + imageName;
                        download_PngFile(str_DownLoadUrl, imageName);
                        strDownLoadStatus = "1";
                        dbhelper.update_DownLoadStatus(imageName, strDownLoadStatus);
                    }
                }
            }
            while (cursor.moveToNext());
        }
        cursor.close();
        //db.close();
    } 

Aucun commentaire:

Enregistrer un commentaire