Let $(X_i)_{i\in I}$ such that $M=\bigcup_{i\in I}\mbox{int}X_i.$ If $f\vert X_i$ is continuous, then $f:M\rightarrow N$ is continuous. 
Let $(X_i)_{i\in I}$ be a family of subsets of $M$ such that $M=\bigcup_{i\in I}\mbox{int}X_i.$ If $f:M\rightarrow N$ is such that $f\vert X_i$ is continuous for each $i\in I$, then $f$ is continuous.

Attempt:
We take $a\in X_i$, $i\in I$, and $\epsilon>0$. Since the restriction is continuous, if we denote by $B=B(f(a);\epsilon)$, we have that $f^{-1}(B)$ is an open subset of $X_i$ which contains $a$. Therefore we conclude that $a\in \mbox{int}(X_i)$.
How to proceed from here in order to finalize the proof? I mean, how would this imply the continuity from the point of view of $f$?
 A: We actually don't need the fact that this is a metric space. Using the more general characterization that a function is continuous if the preimage of every open set is open:
Take an arbitrary open $\mathcal{O}\subseteq N$, then we will show that $f^{-1}(\mathcal{O})$ is open. We will do this by breaking up the preimage into smaller sets that we will show are also open.
$$f^{-1}(\mathcal{O}) = f^{-1}(\mathcal{O}) \cap M = f^{-1}(\mathcal{O}) \cap \bigcup_{i\in I}\operatorname{int}X_i = \bigcup_{i\in I}\left(\, f^{-1}(\mathcal{O}) \cap \operatorname{int}X_i\,\right) = \bigcup_{i\in I} f|_{\operatorname{int}X_i}^{-1}(\mathcal{O})$$
$f|_{\operatorname{int}X_i}$ is continuous because it is a restriction of the continuous function $f|_{X_i}$ (as $\operatorname{int}X_i\subseteq X_i$). Moreover, as $\operatorname{int}X_i$ is the largest open subset of $X_i$, we have that by the continuity of $f|_{X_i}$, $f|_{X_i}^{-1}(\mathcal{O})$ is open in $X_i$ and therefore is a subset of $\operatorname{int}X_i$, so
 $f|_{X_i}^{-1}(\mathcal{O}) = f|_{\operatorname{int}X_i}^{-1}(\mathcal{O})$ is open in $M$, hence the arbitrary union must also be open (i.e., $f^{-1}(\mathcal{O})$). It follows that $f$ is continuous. 
A: Since you take $a$ from $X_i$, you can't conclude $a\in \text{int}(X_i)$. For example, take $M=\Bbb R^2$ and $f:\Bbb R^2\to \Bbb R$ continuous and $X_1=S^1,X_2=\Bbb R^2$, then $\text{int}X_1=\varnothing$.
The correct approach should be look at the interior (in $M$!) of each $X_i$. Take $a\in M$ then exists $i$ such that $a\in\text{int} X_i$. We need only to show $f$ is continuous at $a$ by generality of our choice. Now since $f|_{X_i}$ is continuous at $a$, it must be that $f|_{\text{int} X_i}$ is continuous at $a$ too. So for each $\epsilon>0$ there exist some $\delta>0$ such that 
$$(B|_{\text{int} X_i})_\delta (a)\subset f|_{\text{int} X_i}^{-1}(B_\epsilon(f|_{\text{int}X_i}(a)))\subset f^{-1}(B_\epsilon(f(a))$$
But note that since $\text{int} X_i$ is open in $M$, and $a\in\text{int}X_i$, there must exists some $\delta'>0$ such that $B_{\delta'}(a)\subset (B|_{\text{int} X_i})_\delta (a)$. This completes the proof.
A: Let $x \in X$ and take an $X_i$ such that $x \in \operatorname{int}(X_i)$ so that we have $\delta_0 > 0$ such that $B(x, \delta_0) \subseteq X_i$.
Now let $\varepsilon > 0$ be arbitrary. As $f|X_i$ is continuous there is some $\delta_1 >0$ such that 
$$\text{  (1)  } \forall p \in X_1: d(x,p) < \delta_1 \implies d(f(x), f(p)) < \varepsilon$$
Now take $\delta = \min(\delta_0, \delta_1)$. Then if $p \in X$ and $d(x,p) < \delta$, in particular $p \in B(x,\delta_0)$ so $p \in X_1$ and then as $\delta \le \delta_1$ we know that $d(f(x), f(p)) < \varepsilon$ by (1). So $f$ is continuous at $x$. As this works at any $x$, $f$ is continuous.
A: Let $x\in X$ and $y=f(x)$. Suppose $V$ is a neighborhood of $y$ (in $N$).
The assumption tells you that $x\in\operatorname{int}X_i$, for some $i$, in particular that there exists an open neighborhood $U_0$ of $x$ such that $U_0\subseteq X_i$.
Also by assumption, the restriction of $f$ to $X_i$ is continuous at $X$, so there exists an open neighborhood $U_1$ of $x$ in $X_i$ such that $f(U_1)\subseteq V$.
Since $U_1$ is open in $X_i$, we have $U_1=U_2\cap X_i$, where $U_2$ is open in $M$. Therefore
$$
U_1\cap U_0=(U_2\cap X_i)\cap U_0=U_2\cap(X_i\cap U_0)=U_2\cap U_0
$$
is open in $M$ and, setting $U=U_1\cap U_0$, we have $f(U)\subseteq f(U_1)\subseteq V$. This proves continuity of $f$ at $x$.
