質問

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