java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference
This is the line where the exception is pointing to
  String tot=avg[i+2];
             total=Float.parseFloat(tot);
and
 adapter=new VivaAdapter(Attendance.this,gedata());
I am recieving data in form of string and then converting it into float ,but the app runs fine first time but second time it throws exception
I tried to change avg[i+2].trim() but dint worked
App crashes every alternative time
Eception log:
/AndroidRuntime: FATAL EXCEPTION: main
                                                                                      Process: com.example.rushabh123453.attendancepict, PID: 643
                                                                                      java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference
                                                                                          at java.lang.StringToReal.parseFloat(StringToReal.java:304)
                                                                                          at java.lang.Float.parseFloat(Float.java:306)
                                                                                          at com.example.rushabh123453.attendancepict.Attendance$Networking1.onPostExecute(Attendance.java:189)
                                                                                          at android.os.AsyncTask.finish(AsyncTask.java:636)
                                                                                          at android.os.AsyncTask.access$500(AsyncTask.java:177)
                                                                                          at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                          at android.os.Looper.loop(Looper.java:211)
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:5389)
                                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
 
     
    