문제

I am trying to build a android app where in a part I need to get the containing file names of a specific folder.

String DirectoryPath = "D:\\Images";
File Directory = new File (DirectoryPath);
for(File f:Directory.listFiles())
{
   String name = f.getName();
}

I am using above code to reach and get files but an Error occurs which is a null pointer exception. I am pretty aware what it means but can not solve my problem either.

Edit: I changed the wrong written words sory for it.

도움이 되었습니까?

해결책

This is not possible. Your Android device has no visibility into your PC's filesystem.

As others have mentioned, you'll likely want to transfer these files to the device somehow. Putting them on the SD card is a good choice if the files are large.

If that's not an option, you could instead run a WWW or FTP server on your PC and access the files over the network.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top