double - Can't reproduce android crash -


android keeps on reporting crashes users can't reproduce on phone. can find lines seem incorrect:

cursor.movetofirst(); elechs=cursor.getstring(2); elecls=cursor.getstring(3); gass=cursor.getstring(4); waters=cursor.getstring(5);  cursor.close();  if (elechs.length()!=0){   elechdb=double.valueof(elechs); } else {   elechdb=0.0; }  if (elecls.length()!=0){   elecldb=double.valueof(elecls);} else {   elecldb=0.0; }  if (gass.length()!=0){   gasdb=double.valueof(gass); } else {   gasdb=0.0; }  if (waters.length()!=0){   waterdb=double.valueof(waters); } else {   waterdb=0.0; }  elecldb=double.valueof(elecls); gasdb=double.valueof(gass); waterdb=double.valueof(waters); 

if @ code, doesn't make sense.

i think forgot delete last 3 lines. first check string. if string empty store value zero.

the incorrect last 3 lines try make if cell empty. cause lot of crashes. not on machine.

i believe shouldn't possible make of empty cell.

does know why error doesn't crash phone?

since users getting numberformatexception, should catch exception , perform appropriate action when happens.

if (elechs.length()!=0) {    try {        elechdb=double.valueof(elechs);    } catch (numberformatexception e) {         // perform error handling    } } 

if users getting nullpointerexception, should check if strings null before checking lengths.

if data put in user, should both of above avoid future problems.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -