I have two different site's data stored in localstorage, let's say xyz.com and abc.com. The thing is i can only access the data in which site I'm currently on. How can I access localstorage of abc.com if I'm on xyz.com?
As others have already pointed out in the comments this is not possible.
If you read the documentation for Web Storage API (which consists of both localStorage and sessionStorage) you will see this.
A different Storage object is used for the sessionStorage and localStorage for each origin — they function and are controlled separately.
An origin in this context is defined as this.
Web content's origin is defined by the scheme (protocol), hostname (domain), and port of the URL used to access it. Two objects have the same origin only when the scheme, hostname, and port all match.
https://developer.mozilla.org/en-US/docs/Glossary/Origin
Since you in your example have two different hostnames, they are separate origins and therefore can't access each others localStorage.