just add a test :
String firstWords = "";
if(splitVideoTitle.length>1){
firstWords = splitVideoTitle[0] + " " + splitVideoTitle[1];
}
else firstWords=splitVideoTitle[0];
0
solved Splitting a string caused ArrayIndexOutOfBoundsException [duplicate]