Reputation: 10623
I have successfuly signed in to Sky Drive account using Live Sdk (One Drive) libraries. And have also fetched the files and folder of the Root Directory of My One Drive (Sky Drive) account. Now i want to fetch files when i click on the the folder which is in the root directory.
Upvotes: 0
Views: 447
Reputation: 10623
I got my solution. Its simple and clean code i am here to paste for getting files from any folder id. Just cancatinate 'files' after the folder id, like Folder_id+"/files" and it will retrieve all the files
client.getAsync(Folder_id+"/files", new LiveOperationListener()
{
public void onComplete(LiveOperation operation)
{
final JSONObject result = operation.getResult();
final JSONArray data = result.optJSONArray("data");
if (result.has("error"))
{
final JSONObject error = result.optJSONObject("error");
final String message = error.optString("message");
final String code = error.optString("code");
ShowToast("mssg"+message);
return;
}
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");
final String ids=oneDriveItem.optString("id");
ShowToast("Folder ID = " + ids + ", name = " + itemName);
// ShowToast("Name: "+itemName+"\n"+"Type: "+itemType+"\n ID: "+ oneDriveItem.optString("id"));
}
}
//JSONObject result = operation.getResult();
Log.e("realllt",result.toString() );
}
public void onError(LiveOperationException exception, LiveOperation operation) {
resultTextView.setText("Error reading folder: " + exception.getMessage());
}
});
Upvotes: 1