Dropbox和Android – 通过API调用获取文件名

有谁知道如何获取元数据列表…我的意思是在Android.i的dropBox中我们的app文件夹中存在的文件文件夹需要获取文件文件名称..
现在再次我想在android.i中创建文件夹从android.i reffered dropBox docs.but但是在那里找不到相同的..
Thanx提前.

解决方法:

在这里我做了什么,它对我来说很好.

SavedProperties.selectedAddress是我的静态变量,它包含要创建的文件夹的名称.

在这里

1)检查文件夹是否存在.

2)如果不存在则创建文件夹.

3)将文件上传到该文件夹​​.

    private void loadMetadata() 
    {


        // Metadata
        try 
        {
            Entry existingEntry = mApi.Metadata("/" + SavedProperties.selectedAddress , 1, null, false, null);
            if(existingEntry.isDir)
            {
                Log.d(TAG, "Folder exists : " + existingEntry.fileName());
                uploadPictures("/"+SavedProperties.selectedAddress + "/");
            }
        } 
        catch (DropBoxException  e) 
        {
            Log.d(TAG,"Folder does not exist..." + e.fillInStackTrace());
            try 
            {
                Entry createFolder = mApi.createFolder("/"+SavedProperties.selectedAddress);
                Log.d(TAG,"Folder created..." + createFolder.rev);
                uploadPictures("/"+SavedProperties.selectedAddress + "/");
            } 
            catch (DropBoxException e1)
            {
                 Log.d(TAG,"Create Folder DropBoxException : " + e1.fillInStackTrace() );
            }       
        }
    }

    private void uploadPictures(String uploadTo) 
    {
        // Uploading Pictures....
        FileInputStream inputStream = null;
        try 
        {
            for(int i =0 ; i < selectedImages.length; i++)
            {
                if(selectedImages[i]==0)
                {
                    String path = Picturegallery.images.get(i).toString().replace("file://", "");
                    String filename = Picturegallery.images.get(i).toString().split("/")[Picturegallery.images.get(i).toString().split("/").length-1];
                    File file = new File(path);
                    inputStream = new FileInputStream(file);
                    Entry newEntry = mApi.putFile(uploadTo + filename, inputStream, file.length(), null, null);
                    Log.i(TAG, "The uploaded file's rev is: " + newEntry.rev);
                    //Log.d(TAG,"Picturegallery " + Picturegallery.images.get(i).toString().split("/")[Picturegallery.images.get(i).toString().split("/").length-1]);
                }
            }
            progress.dismiss();
        } catch (DropBoxUnlinkedException e) {
            // User has unlinked, ask them to link again here.
            Log.e(TAG, "User has unlinked.");
        } catch (DropBoxException e) {
            Log.e(TAG, "Something went wrong while uploading.");
        } catch (FileNotFoundException e) {
            Log.e(TAG, "File not found.");
        } 
        finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {}
            }
        }
    }

我在我的情况下使用了android sdk 1.3.1.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...