please give me detailed answer and also mention the difference between local ip address and public ip address
It depends whether you are asking about the cellular Internet or WiFi IP address.
On a cellular network, the device (phone or tablet with a SIM card) may not have any actual IP address of its own. The communication between the cellular network and your device will be based on the way the network addresses the SIM card for phone calls and texts as well as data. The network will have one or more public IP addresses assigned to it, and the cellular networks servers will perform the address translation between the public IP address(es) and the addressing scheme used by the network to communicate with the individual phones. Multiple phones will share a single public IP address.
On a WiFi network, then a phone is exactly the same as any other device connected to the WiFi network. It will have a private address on that network, and it will share the public address that the router has been assigned by the ISP.
A local address is one that is valid only on the local network. For a home network, the local IP addresses are normally assigned by the router and has to be in the subnet supported by the router. The public network is an address that is assigned to the ISP by the Internet authorities and is unique on the Internet. The local private addresses are normally allocated in one of three blocks of IPv4 addresses that are specifically not allowed on the Internet itself.
I hope this helps.
ALL network connected devices need an ip address to identify themselves. Used on a public network they get a public IP address and the company passes the details through their servers to visited sites and collates the return packets so everyone gets the correct replies. Used on a home wifi they would get a private ip and the router handles the transfer out through a public IP.
Our cell phone is provided with an IP address which depend on the network we are connected to. The router we are connected to provides the IP address.
The difference between public and private is just that. One if public (assigned by your ISP/cell provider and accessible by the internet. The other is private, issued by your home router, work etc and protected by a firewall. Unless you poke holes, the private IP's are not accessible by the internet.
Your phone can have both. Your cell provider gives it a public IP and if you connect to wifi, you'll also have a private IP.
The IP address on a cell phone or any other device, is the address of the device on its network. A local IP address is one within the subnet it is on and not routable to the public side; public IP addresses are routable.