vendredi 13 février 2015

Android content uri id as string

In my Android app i use SQLite with content provider. For some (backend) reasons, my tables have _id primary key as VARCHAR.


The problem is:


I need to use content uri with appended id. In all examples what i saw content uri with id looks as



http://content<autority>/<model_or_table>/<long_id>


and adds to UriMatcher as



UriMatcher.add(autority, model_or_id + "/#", uri_id)


and of course thats "/#" matching id works only with digits.


My question is:


There is any way to use content uri with appended String id? Typical id is something like



50c11d774e5e1b99698b6879


and typical content uri must be as



content://com.my.app.autority/Users/50c11d774e5e1b99698b6879


and how to work with uri like this and UriMatcher?


I know that i can write selection directive (WHERE _id = "50c11d774e5e1b99698b6879") to query method, but i need exactly URI or way to project unique string ids to the unique long values in SQLiteDB.


There is any way? Thanks in adwance) Sorry for bad English)


Aucun commentaire:

Enregistrer un commentaire