Skip to content Skip to sidebar Skip to footer

Android Giving Ioexception With 'unable To Create Directory: /tokens' When Using Google Calendar Api

Trying to implement the Calendar Quickstart API into Android but when I declare tokens as demonstrated. private final String TOKENS_DIRECTORY_PATH = 'tokens'; That String is then u

Solution 1:

I used this piece of code.

FiletokenFolder=newFile(Environment.getExternalStorageDirectory() +
            File.separator + TOKENS_DIRECTORY_PATH);
    if (!tokenFolder.exists()) {
        tokenFolder.mkdirs();
    }

    flow = newGoogleAuthorizationCodeFlow.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
            .setDataStoreFactory(newFileDataStoreFactory(tokenFolder))
            .setAccessType("offline")
            .build();

And get permissions to external storage in Android manifest file

EDIT: The methods specified in Google API documentation for Java doesn't seem to work well for Android. Use this github project as a guide for implementing integrating Google APIs into Android applications.

Post a Comment for "Android Giving Ioexception With 'unable To Create Directory: /tokens' When Using Google Calendar Api"