code where the error occurred :
/**
* Get the video name from the download list,
* If there is added video same as it
* Prompts the user that the video has been added to the download list
* Note: The program crashes when you add more than 3 o'clock video
* Throw Error: Android.database.CursorIndexOutOfBoundsException:Index 3 requested, with a size of 3
* @return
*//*
Public String Getdownloadingvideoname () {
Sqlitedatabase db = Openhelper.getreadabledatabase ();
cursor cursor = db.query ("Downloading", NULL, NULL, NULL, NULL, NULL, NULL);
String downloadingvideoname = "";
if (Cursor.movetofirst ()) {//determines if the cursor is empty
Traversing cursors
for (int i = 0; i < Cursor.getcount (); i++) {
Cursor.move (i);//move to the specified record
Downloadingvideoname = cursor.getstring (Cursor.getcolumnindex ("Downloadingfilename"));
}
return downloadingvideoname;
}
Cursor.close ();
Db.close ();
return null;
}*/
Corrected code:
/**
* Get the video name from the download list,
* If there is added video same as it
* Prompts the user that the video has been added to the download list
* @return
*/
Public String Getdownloadingvideoname () {
Sqlitedatabase db = Openhelper.getreadabledatabase ();
cursor cursor = db.query ("Downloading", NULL, NULL, NULL, NULL, NULL, NULL);
String downloadingvideoname = "";
Cursor.movetofirst ();//Determine if the cursor is empty
while (!cursor.isafterlast ()) {
Downloadingvideoname = cursor.getstring (Cursor.getcolumnindex ("Downloadingfilename"));
Cursor.movetonext ();
}
Cursor.close ();
Db.close ();
return downloadingvideoname;
}