Tools

Namespaces

Variants

Views

Actions

Search

Contents

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to list files and folders in Java ME

Comments

29 Sep2009

Article Review by Larry101 (20090929)

This article demonstrates basic use of the PIM (JSR-75) API. It shows how we can list the files and folders available in a certain file system root using this API. This is a fairly basic article, and mainly consists of a code example, showing how to retrieve a list of all the files and folders in the c:/ file system root (usually the phone's built-in memory). The code example shows how to use a FileConnection object and its "list" method to retrieve an enumeration containing all the files and folders at a particular file path. The code also shows how to navigate through this enumeration, how to distinguish between files and folders, and how to find out file and folder size.

The article is very simple, but the code example does a good job of demonstrating several fundamental concepts that that File Connection API is commonly used for. This article is therefore useful reading for those who are new to the API, or who just want to find out how to get a list of files and folders using the API.

Overview

This article demonstrates how to list files and folders of a mobile device. The FileConnection API (JSR-75) offers the FileConnection.list() method for this purpose. The FileConnection.directorySize() and FileConnection.fileSize() methods make it possible to get directory and file sizes.