Pir Fahim Shah
Pir Fahim Shah

Reputation: 10623

How to get files name from sky drive and show in list

I am building Skydrive application where i want to show all the home directory(Root folder) files in list. I have signed in successfuly but i don't know how to get all the files name from the Home directory of my Skydrive account

Upvotes: 1

Views: 384

Answers (1)

Peter Nied
Peter Nied

Reputation: 1885

It sounds like using the LiveSDK for Android would get you the details you need from OneDrive, https://github.com/liveservices/LiveSDK-for-Android/

Here is a limited example that will get you the item names and types from the root of a OneDrive:

mClient = (LiveConnectClient) mApp.getConnectClient();
mClient.getAsync("me/skydrive/files", new LiveOperationListener() {
    @Override 
    public void onComplete(final LiveOperation operation) { 
        final JSONObject result = operation.getResult(); 
        if (result.has("error")) { 
            final JSONObject error = result.optJSONObject("error"); 
            final String message = error.optString("message"); 
            final String code = error.optString("code"); 
            showToast(code + ": " + message); 
            return; 
        } 

        final JSONArray data = result.optJSONArray("data");
        for (int i = 0; i < data.length(); i++) { 
            final JSONObject oneDriveItem = data.optJSONObject(i);
            if (oneDriveItem != null) {
                final String itemName = oneDriveItem.optString("name");
                final String itemType = oneDriveItem.optString("type");
                // Update your adapter with the contents of the folder
            } 
        } 
    }
});

You can see the source of this example https://github.com/liveservices/LiveSDK-for-Android/blob/master/sample/src/com/microsoft/live/sample/skydrive/SkyDriveActivity.java#L759 I would highly recommend working with this sample application in order to see what is possible with the LiveSDK.

Upvotes: 1

Related Questions