Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Data Persistence Introduction to Data Persistence Handling an Exception

Guy Bridge
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Guy Bridge
Android Development Techdegree Graduate 24,991 Points

Hi, I'm trying to put the following code in a try/catch however I keep getting the compile error.

I get this compile error:

JavaTester.java:22: error: exception Exception is never thrown in body of corresponding try statement } catch(Exception ex) { ^ 1 error

I've compiled it locally and it runs, although I removed the InputStream and copyFile method.

CodeChallenge.java
// assetManager, assetName, and fileToWrite have been initialized elsewhere
try
{
InputStream in = assetManager.open(assetName);
FileOutputStream out = new FileOutputStream(fileToWrite);
copyFile(in, out);
}
catch(Exception e)
{
  e.printStackTrace();
}
Sandro Meschiari
Sandro Meschiari
18,418 Points

try to clean the project, build=> clean Project

4 Answers

Harry James
Harry James
14,780 Points

Hey Guy!

I'm getting the same problem on my side as well - there must be an issue with this Code Challenge.

I've gone ahead and reported this to the Treehouse Support team and will post back onto here if I get any updates about this for you (It shouldn't be long - they usually respond pretty quickly)

Speak to you soon and sorry about the issue!

Harry James
Harry James
14,780 Points

Hello again!

Just posting an update for you that this has now been passed along and the team are working on the issue.

Peter Do
Peter Do
12,294 Points

same issue here...

Peter Do
Peter Do
12,294 Points

Harry, any answer on this?

Harry James
Harry James
14,780 Points

Hey Peter!

I've no news as of yet but will wait a couple more days before I ask for another update on this for you.

Again, sorry for the inconvenience and I'll speak to you shortly!

Peter Do
Peter Do
12,294 Points

this is fixed, thanks Harry!

Harry James
Harry James
14,780 Points

Woohoo!

Glad everything is working again, have fun with the Android courses :D