Welcome to the Ranch!
I don't see anything wrong with the code you posted, but it isn't complete. You need to use LogCat to find out what exception or error is happening that causes the crash. If you are using an IDE
then there should be a view for LogCat, and if not there is an ADB command to view it.
Also, in the future, please UseCodeTags
(<- read link for how), it makes the code easier to read.