Android Question GoogleDrive via API V3: How to delete file on GoogleDrive ? [SOLVED]

Armani

Member
Hello all,

I'm using GoogleDrive via API V3.

I read all/most related threads in forum and do not found how to delete file/folder from Google Drive (in particular here from fredo and here from mw71).
I'm not able to find solution myself by modifiying existing class..

Is someone may help?
Please give me an explicit thread or code example.

Thanks in advance,
 

Armani

Member
Hello all,

For those may be interested to do the same, I solve my question.

So, as I understand it, initial threads and code snippet made by fredo and mw71 have been made long ago, and some parts are now obsolete.
(i.e. Class HttpJob and Service HttpUtils2Service initially provided in the thread can be removed and replace by Library OkHttpUtils2.)

OkHttpUtils2 allow use of member Delete in HttpJob.
So, new Sub can be added in class module GoogleDrive.bas



B4X:
Sub DeleteFile(FileID As String) As ResumableSub
    
    Dim h_delete As HttpJob
    
    h_delete.Initialize("",Me)   
    h_delete.Delete("https://www.googleapis.com/drive/v3/files/"&FileID)
    h_delete.GetRequest.SetHeader("Authorization", "Bearer " & myAccessToken)
    
    Wait For (h_delete) JobDone(h_delete As HttpJob)
    
    If h_delete.Success Then           
        CallSubDelayed2(evModule, evName & "_FileDeleted", "{OK}")
    Else
        CallSubDelayed2(evModule, evName & "_FileDeleted", "{ERR}")
    End If
    
    h_delete.Release
    Return Null
End Sub


Hope it may help others, at least fix my problem :)
 
Upvote 0
Top