Why do we specify namespace in android xml file?

Vinoth picture Vinoth · May 2, 2011 · Viewed 21.7k times · Source

When we write a xml based layout in Android we use the string "xmlns:android="http://schemas.android.com/apk/res/android".

From the books I read it says that this is a namespace, but why do we use this? The link doesn't even exist. So what is the use of this?

Answer

Kartik Domadiya picture Kartik Domadiya · May 2, 2011

From developer.android.com

xmlns:android

Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".

xmlns:android is for identification that this xml is used for android, not for other function.

Namespaces uniquely identify code/libraries. If I write an api that uses all the same names and such as the android api the only way to distinguish between my api and android api is to use the android namespace, or mine.

You can further refer http://en.wikipedia.org/wiki/XML_namespace