Grabbing chunks of code from the internet and "bolting them together" isn't development: it doesn't produce high quality code.
What it does produce is a mess that might or might not do what you want, but that will probably need some changes to meet your exact requirements.
And that means that without knowing exactly what you want to achieve with your app - and we have no idea - we can't tell you what is "necessary" and what is "unnecessary".
And since that code doesn't even appear to compile:
for (int i = 0; i 55)
There isn't anything we can recommend, other than say "work out what each part is meant to do, and how it does it - then use it as a template to write your own code to do exactly what you want". That way, you will get better code with no "unnecessary coding".