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 trialIrmak Topkaya
1,072 Pointsi can't see images on my virtual device
Even i did exactly the same thing in the video, i could not see the images on my virtual device. I can run the code successfully, i didn't get any error but I didn't see images too. I checked the image files from Android Device Monitor like in the previous video, and i can see the files. Can you help me to understand the issue?
3 Answers
Ureche Gabriel-Terry
5,566 PointsThat's work for me
public static File[] listFiles(Context context) {
File fileDirectory = context.getFilesDir();
File[] filteredFiles = fileDirectory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if(pathname.getAbsolutePath().contains(".jpg")) {
return true;
} else {
return false;
}
}
});
Rob Randell
13,809 PointsI had this issue but went back to the 'listFiles' method and found some issues in there. Since some of this method was auto-generated by Studio, some of the key variables may be slightly different. I double checked against the code in the video and found inconsistencies in my code. I corrected these and the photos appear now in the emulator.
Irmak Topkaya
1,072 PointsThank you very much! Actually I saw some differences between my code and the original one and I tried to change that but now I am getting another error which is basically related with content assist feature of Android Studio. I tried many times with alt+enter to initialize my values but I am getting different options when I hit alt+enter. The video is creating setting page in shared preferences stage.
Milan Tailor
5,132 PointsWas this ever solved? I'm not getting any errors but the grid remains empty.
Steffy Joseph
1,436 PointsSteffy Joseph
1,436 PointsThat works, insted of fileDirectory.getAbsolutePath().contains(".jpg") use pathname.getAbsolutePath().contains(".jpg")