2

I am having a look at here from github.

I can create a file and a folder successfully by reading the code provided in github. But I am not being able to edit the file or create a file/folder in any specific folder.

The main problem would be using emulator, but I am not sure. I am using GenyMotion

I have also copied the ID of a file/folder using

showMessage("Created a file in App Folder: "
                    + result.getDriveFile().getDriveId());

and

showMessage("Created a folder: " + result.getDriveFolder().getDriveId());

lines of code .

Then I changed

public static final String EXISTING_FOLDER_ID = "CAESABjACiCShczj8lI=";//changed this
    public static final String EXISTING_FILE_ID = "0ByfSjdPVs9MZTHBmMVdSeWxaNTg";

of BaseActivity. Still I am getting the same output.

"Cannot find DriveId. Are you authorized to view this file?"

Can anyone point me what am I doing wrong here?

Thank you!!

Nabin
  • 11,216
  • 8
  • 63
  • 98

1 Answers1

2

I do believe that 'result.getDriveFile().getDriveId()' gives you a 'DriveId', an ID used by GDAA only. The 'EXISTING_FILE_ID' refers to another ID, so called ResourceID. You have to use that one. See SO 21800257. The ResourceId is the original ID used in older RESTful API, and the only one that you can use when referring to the Drive object across different devices (DriveID is device specific). ResourceID can also be seen as a part of the URL address of the object.

BTW. the shortest answer to your question is:

result.getDriveFile().getDriveId().getResourceId();

But you may get NULL if you're too quick see SO 22874657 .

Good Luck.

Community
  • 1
  • 1
seanpj
  • 6,735
  • 2
  • 33
  • 54
  • You may also look at this code that has both GDAA and RESTful APIs implemented side-by-side. It'll give you some idea about the relation of these two (https://github.com/seanpjanson/GDAADemo). Another point to consider is, that ResourceId is not immediately available, GDAA must commit the file / folder first, – seanpj Feb 24 '15 at 11:54
  • How much time does it need to commit? Thank you for the information. That method, __getResourceId()__ helped me alot – Nabin Feb 25 '15 at 05:06
  • It was one of the reasons I quit GDAA and backed off to RESTful. There was a long discussion about the requestSync() (grep it here on SO). Some claimed it works, but I could never get reliable results (minutes, hours latency - totally random). Then they added some sync callbacks, but I was already gone from the GDAA world, so I did not pay attention to it anymore. – seanpj Feb 25 '15 at 14:01
  • Thank you seanpj, can you help me with RESTful? Some helping tutorial? And if it's possible, can you give me your email address? Thank you so much once again. – Nabin Feb 26 '15 at 00:59
  • RESTful's here: https://developers.google.com/drive/v2/reference/. You will definitely need at least the playground to test Drive related stuff. See the bottom of this page: https://developers.google.com/drive/v2/reference/files/list – seanpj Feb 28 '15 at 03:43
  • Thank you so much for the help. I can work at least at the bottom level. Your repo at github was useful. – Nabin Feb 28 '15 at 05:15