views:

251

answers:

2

I came across the following two lines in AndroidMenifest.xml file of my android application:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  1. Why we have write "encoding" in <xml> tag, what is the purpose of it?
  2. What is the purpose of writing 2nd line ?

if anybody know this, may share their knowledge to let me clear regarding this 2 lines

Thanx - paresh

A: 

First line is not required for writing your xml, but it is good practice to have it as the first line of your XML and if you are using any other encoding then it becomes necessary.
Second line is required because manifest should be the root node of Android Manifest xml. And as a matter of fact it gets closed at the end of file by </manifest> just like any other node.

bhups
then i mean to ask about "xmlns:android="http://schemas.android.com/apk/res/android"" in 2nd line ...
PM - Paresh Mayani
then probably you should edit your question to reflect the same.
bhups
+1  A: 

Hi,

Since you found out the first line by yourself, I'll explain you only the second. It just sets up the android XML namespace. When using own resources, you should add their namespaces too, like:

xmlns:myapp="http://schemas.android.com/apk/res/com.mypackage

This will declare the myapp namespace.

ognian