im testing to add 300 contacts in my app and it was doing fine with desire but in galaxy it crashes and does not show my 300 contacts and they erased the contacts after the crash .
anyone saw this?
im testing to add 300 contacts in my app and it was doing fine with desire but in galaxy it crashes and does not show my 300 contacts and they erased the contacts after the crash .
anyone saw this?
simple answer:
StringIndexOutOfBoundsException
Thrown by String methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt method, this exception also is thrown when the index is equal to the size of the string.
maybe you are accessing your string with charAt() method? either way, accessing a position in the string that is not there will return an array like yours.
String myString;
myString = "Hello";
System.out.println(charAt(10)); will cause a stringsIndexOutOfBoundsException
Detailed answer:
explains what happens before any sort of indexoutofboundsexception is thrown. I've used arrays as a base example.
It means that you are iterating beyond the 300 contacts. Ut has reached the end of the array and tried to access the next value which is empty. this returns an indexoutofboundsexception.
When looping through your array you need to understand that element one, the first element in the array, is defined as 0. Because java has an index that starts at 0. So accessing th first element you would do like so myArray[0];
so If you want to access the last element of your array you do something like myArray[myArray.size - 1]
So if you have 10 elements you will have an array that looks like this:
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] Note there is no 10 as it starts from 0.
so when you try to access element 10 you do so like this. myArray[myArray.size-1]
myArray.size will return the size of the array which is equal to 10 then we minus 1 to get a value of 9 then we can access the tenth element by putting value 9.
This is a neat of of catching any errors without your application during run time. instead it produces a message for the user to notify them of the error.
PK
Well i guess it is the Samsung Galaxy S, still adding it in the view ... that is why it will take some time to render it on the device!