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
james white
78,399 PointsGetting 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..
2 Answers
J.D. Sandifer
18,813 PointsThanks for listing this so other people can avoid the same problem!
James Chakanyuka
4,916 PointsThank You
James Chakanyuka
4,916 PointsJames Chakanyuka
4,916 PointsThank You