如何读取文件夹ID文件在一个驱动器(天空驱动器)? [英] How to read files from Folder id in one drive (sky drive)?

查看:235
本文介绍了如何读取文件夹ID文件在一个驱动器(天空驱动器)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我successfuly中使用Live SDK(一个驱动器)库天空驱动帐户。而且还获取的文件和我的一个驱动器(天空驱动器)账户的根目录文件夹中。现在我想,当我在这是在根目录下的文件夹点击获取文件。<​​/ P>

解决方案

我得到了我的解决方案。其简洁明快code我在这里粘贴任何文件夹ID获取文件。
只是cancatinate文件的文件夹ID后, 像Folder_id +/文件,它会检索所有
文件

  client.getAsync(Folder_id +/文件,新LiveOperationListener()
    {
        公共无效的onComplete(LiveOperation操作)
        {
              最终的JSONObject结果= operation.getResult();
             最后JSONArray数据= result.optJSONArray(数据);             如果(result.has(错误))
                {
                    最终的JSONObject错误= result.optJSONObject(错误);
                    最终字符串消息= error.optString(信息);
                    最后弦乐code = error.optString(code);
                    ShowToast(mssg+消息);
                    返回;
                }                的for(int i = 0; I&LT; data.length();我++)
                {
                    最终的JSONObject oneDriveItem = data.optJSONObject(I)
                    如果(oneDriveItem!= NULL){
                        最后弦乐ITEMNAME = oneDriveItem.optString(名称);
                        最后弦乐ITEMTYPE = oneDriveItem.optString(类型);
                        最后字符串ID = oneDriveItem.optString(ID);                        ShowToast(文件夹ID =+ IDS +,NAME =+ ITEMNAME);
                   // ShowToast(姓名:+ ITEMNAME +\\ n+型:+ ITEMTYPE +\\ n ID:+ oneDriveItem.optString(ID));                    }
                }
            // JSONObject的结果= operation.getResult();
            Log.e(realllt,result.toString());        }
        公共无效onerror的(LiveOperationException例外,LiveOperation操作){
            resultTextView.setText(错误读取文件夹:+ exception.getMessage());
        }
    });

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.

解决方案

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());
        }
    });

这篇关于如何读取文件夹ID文件在一个驱动器(天空驱动器)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆