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

Getting the Internal File Directory

Quiz Question (from Android Data Persistence, File Storage)

In the code below, call the Context method that gets the internal file directory

This is a MANDATORY question (you can't get it wrong and still move on): http://teamtreehouse.com/library/android-data-persistence/file-storage/getting-the-internal-file-directory

I knew the answer, but the it kept telling me this was wrong:

public File getInternalFilePath(Context context, String fileName) {
  File fileDir = context.getFilesDir;
  File fileToWrite = new File(fileDir, fileName);
  return file;
}

Can anyway guess why the above was wrong?

After an hour of forum searching I found this post:

https://teamtreehouse.com/forum/displaying-images-in-grid-empty-grid

which had this line (amongst much other code):

File fileDirectory = context.getFilesDir(); 

This is so no one wastes an hour for a pair of parenthesis..

Thank You

2 Answers

Thanks for listing this so other people can avoid the same problem!

Thank You