无法从 android 中的 Dropbox 获取文件列表

Can't get the list of files from Dropbox in android

我无法从 Dropbox 中获取文件列表。

 package com.example.contactmaster.dropbox_api;

    import java.util.ArrayList;
    import android.os.AsyncTask;

    import com.dropbox.client2.DropboxAPI;
    import com.dropbox.client2.DropboxAPI.Entry;
    import com.dropbox.client2.android.AndroidAuthSession;
    import com.dropbox.client2.exception.DropboxException;

    public class ListFiles extends AsyncTask<Void, Void, Boolean> {
        private DropboxAPI<AndroidAuthSession> dropboxApi;
        private String path;

        public ListFiles(DropboxAPI<AndroidAuthSession> dropbox, String fILE_DIR) {
            // TODO Auto-generated constructor stub
            dropboxApi = dropbox;
            path = fILE_DIR;
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            System.out.println("=== List File ");
            ArrayList<String> files = new ArrayList<String>();
            try {
                Entry directory = dropboxApi.metadata(path, 1000, null, true, null);
                for (Entry entry : directory.contents) {
                    if (!entry.isDir)
                        files.add(entry.fileName());
                    else
                        files.add("___" + entry.fileName());
                }

                System.out.println("=== Array List : " + files.size());
            } catch (DropboxException e) {
                e.printStackTrace();
            }

            return true;
        }

    }

我创建了这个 AsyncTask 并从 MainActivity 调用。

我的日志文件的错误代码是

05-21 18:52:32.702: W/genymotion_audio(122): out_write() limiting sleep time 58049 to 23219 
05-21 18:52:32.710: I/System.out(7603): === List File 
05-21 18:52:32.726: W/genymotion_audio(122): out_write() limiting sleep time 28049 to 23219
05-21 18:52:33.978: W/System.err(7603): DropboxServerException (nginx): 400 Bad Request (App folder (sandbox) access attempt failed because this app is not configured to have an app folder.  Should your access type be 'dropbox' instead?)
05-21 18:52:33.978: W/System.err(7603):     at com.dropbox.client2.RESTUtility.parseAsJSON(Unknown Source)
05-21 18:52:33.982: W/System.err(7603):     at com.dropbox.client2.RESTUtility.execute(Unknown Source)
05-21 18:52:33.990: W/System.err(7603):     at com.dropbox.client2.RESTUtility.execute(Unknown Source) 
05-21 18:52:33.994: W/System.err(7603):     at com.dropbox.client2.RESTUtility.streamRequest(Unknown Source) 
05-21 18:52:33.994: W/System.err(7603):     at com.dropbox.client2.RESTUtility.request(Unknown Source)
05-21 18:52:33.994: W/System.err(7603):     at com.dropbox.client2.DropboxAPI.metadata(Unknown Source)
05-21 18:52:33.998: W/System.err(7603):     at com.example.contactmaster.dropbox_api.ListFiles.doInBackground(ListFiles.java:26) 
05-21 18:52:33.998: W/System.err(7603):     at com.example.contactmaster.dropbox_api.ListFiles.doInBackground(ListFiles.java:1)    05-21 18:52:33.998: W/System.err(7603):  at android.os.AsyncTask.call(AsyncTask.java:287) 
05-21 18:52:33.998: W/System.err(7603):     at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
05-21 18:52:33.998: W/System.err(7603):     at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:230) 
05-21 18:52:33.998: W/System.err(7603):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)     
05-21 18:52:33.998: W/System.err(7603):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)    
05-21 18:52:34.002: W/System.err(7603):     at java.lang.Thread.run(Thread.java:856)
if (key != null && secret != null) {
    AccessTokenPair token = new AccessTokenPair(key, secret);
    session = new AndroidAuthSession(appKeyPair, ACCESS_TYPE, token);
} else {
    session = new AndroidAuthSession(appKeyPair, ACCESS_TYPE);
}

dropboxApi = new DropboxAPI<AndroidAuthSession>(session);