Search code examples
androidonedrive

List files from the root folder with onedrive Android API


I'm using OneDrive in an Android App and I can't find how to list the root folder contents.

I'm using the LiveSDK

Thanks for your help


Solution

  • You can issue a request against the users root OneDrive folder at me/skydrive/files

    GET https://apis.live.net/v5.0/me/skydrive/files HTTP/1.1
    Authorization: bearer EwCIAq...
    Host: apis.live.net
    

    If you were using the LiveSDK for Android then your code would need to look something like this once you'd setup your LiveConnectClient running.

     mClient.getAsync("me/skydrive/files", new LiveOperationListener() {
    
         @Override
         public void OnComplete(LiveOperation operation) {
             JSONObject result = operation.getResult();
             // Use this information to update your application
         }
    
     });
    

    To see a copy of this code running you can look into the sample Android Application for its implementation.