public String getDeepestFolderId ( ) { if ( filesChain . isEmpty ( ) ) { return "root" ; } JSONObject last = filesChain . getLast ( ) ; if ( GoogleDrive . MIME_TYPE_DIRECTORY . equals ( last . getString ( "mimeType" ) ) ) { return last . getString ( "id" ) ; } // If last is a blob, we return the parent id : if ( filesChain . size ( ) == 1 ) { return "root" ; } return filesChain . get ( filesChain . size ( ) - 2 ) . getString ( "id" ) ; }
If this remote path does not exist this is the last existing id or root .