1

The new Google Drive Android API has 2 types of string IDs available, the 'resource' ID and the 'encoded' ID.

'encoded' id from DriveId.encodeToString()
"DriveId:CAESHDBCMW1RVVcyYUZKZmRhakIzMDBVbXMYjAUgssy8yYFRTTNKRU55"

'resource' id from DriveId.getResourceId()
"UW2aFJfdajB3M3JENy00Ums0B1mQ"

In the process I end-up with a string that can contain any one of them (result of some timing issues). My question is:

If I need to 'parse' the string in order to identify the type, is there a characteristic I can rely on? For instance:

  • 'encoded' id will always start with 'DriveId:' substring
  • 'resource' id will have some length limit
  • can I abuse error return from 'decodeFromString()'?
  • or should I form (pre-pend) the string container with my own tag? What could be the minimal 'safe' tag (i.e. what will never appear in the beginning of these ids) ?

Please point me in the right direction so I don't have to re-do it with the next release.

I have run into yet another issue that should be mentioned here so others don't waste time falling into the same pit. The 'resourceID' can be ported and will remain unique for the object it identifies, where 'encodedID' has only 'device' scope. Means that you CAN'T transfer 'encodedID' to another device (with the same account) and try to retrieve file/folder with it. So I assume it is unique to a Google Play Services instance.

seanpj
  • 6,735
  • 2
  • 33
  • 54

1 Answers1

2

Please do not rely on any formatting of either ID type. This are subject to change without notice.

If you need to use both, and track the differences between them you should have your own method of doing so within your app.

Really, you should probably always just store the encoded ID since this one is always guaranteed to present, and if it contains a resourceId, its easy to get back out.

Cheryl Simon
  • 46,552
  • 15
  • 93
  • 82
  • Thanks, that's what I thought. I would love to work with encodedIDs, but unfortunately, my processing starts with 'resourceIDs' from RESTful API (need to grab thumbnails, description,... from the old version) and I turn it asynchronously to 'encodedIds'. That is where I momentarily end up with the mix (you know the joy multi-threaded designs :-). And all of it will go away as soon as all the functionality is in place anyway, right? – seanpj Apr 03 '14 at 15:51