Seems like a repetition of code for each videoName* variable. Can be shortened if you use an array: "String[] videoNames". Then interate throught the array: "for (String videoName : videoNames) { ... }" after it has been populated. Unless your code below is not complete or doesn't show the whole picture, videoName2 and videoName3 always seem to contain an empty String.