Java me 文件连接+;j2me

Java me 文件连接+;j2me,java-me,jsr75,Java Me,Jsr75,我想使应用程序,我可以得到所有的图像,无论是在手机或外部存储器。我想在我的应用程序中导入所有这些图像。怎么可能呢?我知道通过文件连接是可能的。但没有得到确切的想法 使用FileSystemRegistry.listRoots()获取所有文件系统根 使用FileConnection fconn=(FileConnection)连接器依次打开到每个根目录的连接。打开(根目录) 使用fconn.List()列出文件夹 对于列表中的每个条目,如果它以图像扩展名(file.getName().endsWi

我想使应用程序,我可以得到所有的图像,无论是在手机或外部存储器。我想在我的应用程序中导入所有这些图像。怎么可能呢?我知道通过文件连接是可能的。但没有得到确切的想法

  • 使用
    FileSystemRegistry.listRoots()获取所有文件系统根
  • 使用
    FileConnection fconn=(FileConnection)连接器依次打开到每个根目录的连接。打开(根目录)
  • 使用
    fconn.List()
    列出文件夹
  • 对于列表中的每个条目,如果它以图像扩展名(
    file.getName().endsWith(“.png”)
    等)结尾,则它是一个图像
  • 如果条目是文件夹(
    file.isDirectory()
    返回true),则使用
    fconn.setFileConnection(folder)
    遍历该目录/
  • 对所有根目录中的所有文件夹执行相同的递归操作

  • 下面是我曾经用于我的应用程序的代码片段。在funkybros的步骤中,它或多或少也是这样

     protected void showFiles() {
            if (path == null) {
                Enumeration e = FileSystemRegistry.listRoots();
                path = DATAHEAD; //DATAHEAD = file:///
                setTitle(path);
                while (e.hasMoreElements()) {
                    String root = (String) e.nextElement();
                    append(root, null);
                }
                myForm.getDisplay().setCurrent(this);
            } else {
                            //this if-else just sets the title of the Listing Form
                            if (selectedItem != null) {
                                setTitle(path + selectedItem);
                            }
                            else {
                                setTitle(path);
                            }
                try {
    // works when users opens a directory, creates a connection to that directory
                    if (selectedItem != null) {
                        fileConncetion = (FileConnection) Connector.open(path + selectedItem, Connector.READ);
                    } else // works when presses 'Back' to go one level above/up
                    {
                        fileConncetion = (FileConnection) Connector.open(path, Connector.READ);
                    }
    // Check if the selected item is a directory
                    if (fileConncetion.isDirectory()) {
                        if (selectedItem != null) {
                            path = path + selectedItem;
                            selectedItem = null;
                        }
                        //gathers the directory elements
                        Enumeration files = fileConncetion.list();
                        while (files.hasMoreElements()) {
                            String file = (String) files.nextElement();
                            append(file, null);
                        }
    //
                        myForm.getDisplay().setCurrent(this);
                        try {
                            if (fileConncetion != null) {
                                fileConncetion.close();
                                fileConncetion = null;
                            }
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                    }//if (fileConncetion.isDirectory())
                    else {
                        System.out.println(path);
                        //if it gets a file then calls the publishToServer() method
                        myForm.publishToServer();
    
                    }
    

    感谢您的回复,但我无法在MOTORLA A1200中打开此应用程序。我曾尝试安装该应用程序,但该应用程序关闭,没有给出文件列表我编写了什么url将图像导入到我的应用程序中。该图像位于手机内存中的文件夹名称内--我的图像我以为您需要“所有的图像,无论它在手机或外部存储器中的哪个位置”?是的,我想要它。在j2me中如何做到这一点?按照我上面描述的步骤。或多或少……特别是,它没有实现funkybro的步骤5或6。