Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top