Get file ID in skydrive SDK Android -
i'm making app can download file skydrive. app using skydrive sdk. i've found piece of code can download file skydrive android device below:
final livedownloadoperation operation = mclient.downloadasync(fileid + "/content", file, new livedownloadoperationlistener() { @override public void ondownloadprogress(int totalbytes, int bytesremaining, livedownloadoperation operation) { int percentcompleted = computeprecentcompleted(totalbytes, bytesremaining); progressdialog.setprogress(percentcompleted); } @override public void ondownloadfailed(liveoperationexception exception, livedownloadoperation operation) { progressdialog.dismiss(); showtoast(exception.getmessage()); } @override public void ondownloadcompleted(livedownloadoperation operation) { progressdialog.dismiss(); showtoast("file downloaded."); } });
but don't know fileid skydrive make code works. it's awesome if have example
i've find solution self. list of file, compare finding file id. here code:
public list<dfile> getfileidfromname(string filename) { dfile res = null; // list<dfile> dolphinlistfile = getlistfile(dir_home); // (dfile dolphin : dolphinlistfile) { // if (dolphin.getfilename().compareto(filename) == 0) // res = dolphin; // } boolean cangetid = true; if (!isloggedin()) { ongetidfromfilenamechecked(null, "not logged in or check session false"); cangetid = false; } if (cangetid) { mfilelist = new arraylist<dfile>(); final string mfilename = filename; mclient.getasync(dir_home + "/files", new liveoperationlistener() { @override public void oncomplete(liveoperation operation) { jsonobject result = operation.getresult(); if (result.has(jsonkeys.error)) { jsonobject error = result.optjsonobject(jsonkeys.error); string message = error.optstring(jsonkeys.message); string code = error.optstring(jsonkeys.code); log.d("dolphin download err", code + ": " + message); return; } jsonarray data = result.optjsonarray(jsonkeys.data); (int = 0; < data.length(); i++) { skydriveobject skydriveobj = skydriveobject.create(data.optjsonobject(i)); skydriveobj.accept(new visitor() { @override public void visit(skydrivealbum album) { mdfile = new dfile(album.getid(), "n/a", album.getname(), dfile.filehost_skydrive, dfile.filetype_album); } @override public void visit(skydrivephoto photo) { mdfile = new dfile(photo.getid(), "n/a", photo.getname(), dfile.filehost_skydrive, dfile.filetype_photo); } @override public void visit(skydrivefolder folder) { mdfile = new dfile(folder.getid(), "n/a", folder.getname(), dfile.filehost_skydrive, dfile.filetype_folder); } @override public void visit(skydrivefile file) { mdfile = new dfile(file.getid(), "n/a", file.getname(), dfile.filehost_skydrive, dfile.filetype_file); } @override public void visit(skydrivevideo video) { mdfile = new dfile(video.getid(), "n/a", video.getname(), dfile.filehost_skydrive, dfile.filetype_video); } @override public void visit(skydriveaudio audio) { mdfile = new dfile(audio.getid(), "n/a", audio.getname(), dfile.filehost_skydrive, dfile.filetype_audio); } }); if (mdfile.getfilename().compareto(mfilename) == 0) { mfilelist.add(mdfile); } } ongetidfromfilenamechecked(mfilelist, "complete"); } @override public void onerror(liveoperationexception exception, liveoperation operation) { log.d("dolphin download err", exception.getmessage()); ongetlistchecked(null, exception.getmessage()); } }); } return mfilelist; }
Comments
Post a Comment