Why would you "guess"? The stack trace tells you exactly in which line the exception occurs. Which line is it?
Yeah I understand.I followed and got my app problems resolved.Thank you for your responses.
Problems I had at the beginning were:
1.sounds on/off button
2.Updating arraylist items.
Solutions I tried:
In soundsActivity a user can turn on/off sounds by clicking on a button.My code for it is:
I wrote the following code
in onCreate() method to turn on the sounds when app is restarted.
2.Updating arraylist problem.
Initially my arraylist will look like :
5.ItemName5 ..........when user clicks on any of the items he will be directed to that particular details activity.This worked fine as far as user doesn't delete any item.When an item is deleted from it ,arraylist should look as: (say ItemName2 is deleted)
when ItemName3 is clicked application got crashed.Error was curcor indexOutfBounds:index requested 0 with size 0 exception as I mentioned earlier.I tried to solve it this way:
now my application is working fine.earlier the above block of code I tried was:
The application is working fine so far.I am curious to know whether my approach for sounds on/off button is correct.Because I googled about the problem and what I discovered was
people used the following code to mute/unmute:
I tried this in my app. It muted my app sound but when I restarted the app it got the app sound still muted.I was unable to increase the volume either.so I used setStreamVolume().
Appllication is working fine.Kindly see the above codes and suggest any best practices..Thank you Ulf Sir.