1

i'm developing an app using google drive SDK currently on Android using eclipse, i encounter an error which happen everytime i try to update modified date from file that i upload. this my code.

com.google.api.services.drive.model.File f=null;
        File a=new File(file[1]);
        com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
        body.setTitle(file[1].substring(file[1].lastIndexOf("/")+1, file[1].length()));
        Uri selectedUri = Uri.fromFile(a);
        String fileExtension 
         = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString());
        String mimeType 
         = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
        body.setMimeType(mimeType);
        System.out.println(DateTime.parseRfc3339(file[2]));
        body.setModifiedDate(DateTime.parseRfc3339(file[2]));
        //this modified date code causing error
        FileContent mediaContent = new FileContent(mimeType, a);
        try {
            f = service.files().insert(body, mediaContent).setConvert(true).execute();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            handleException(e);
        }

can someone tell me how to setModifiedDate in correct way, i'm totally stuck here..
thanks in advance

4

1 に答える 1

2

You can only set the date on a files().update not on files().insert. Also make sure you set the parameter setModifiedDate to true if you use update.

service.files().update(body,mediacontent).setSetModifiedDate(true).execute();

于 2012-10-26T09:08:02.277 に答える