Listing all files in a directory in Android

Let’s say we have a directory in device’s storage called “mydir” and there are files inside it. By using this snippet we can list all names of that files and folders:

String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/maktabamajaziya";
String downloadedbooks = "";
File directory = new File(path);
File[] files = directory.listFiles();
for (int i = 0; i < files.length; i++)
{
	downloadedbooks += files[i].getName() + "\n";
}

Now downloadedbooks string variable contains all files and folders name.

Getting boored? Why not playing a game?

Power Block

Tiki Solitaire

Pet Connect

Cake Shop

Jewels Blitz 3

Forest Match

Bike Racing

Aquador

Solitaire Swift

Bubble Shooter Classic HD

Black and white snake

Leave a Reply

Your email address will not be published. Required fields are marked *