[Monodroid] Where is BaseColumns ?

Jonathan Pryor jpryor at novell.com
Fri Mar 4 07:42:43 EST 2011


On Mar 4, 2011, at 3:29 AM, Jasper wrote:
>  But I can not find 'BaseColumns' class. The most similar class that I found was 'BaseColumnsConst' with the same parameters but I can not inherit from it :(

You don't need to inherit from android.provider.BaseColumns. A common Java technique is to place constants into an interface, then inherit from the interface so that the constants can be used directly. This is what android.provider.BaseColumns does -- it has no methods, only constants, and MonoDroid moves the constants into a BaseColumnsConsts type (because in C# an interface can't have static members, so it's ~impossible to represent this Java construct in C#).

Since android.provider.BaseColumns provides no methods, there is no need to inherit it, so just use BaseColumnsConsts.Id instead of inheriting from BaseColumns and using _ID.

 - Jon



More information about the Monodroid mailing list