I'm dealing with fragments.
I have an Activity
and different fragments
.
Each fragment
need the access to a Class(call it X)
that allow it to access a database, but, because I have a lot of fragments, I don't want to create a different instance of the Class X
in every fragment as I think it will require lots of memory
.
So how can I do?
I wrote something like this (with a getter), but it doesn't work!
public class MyActivity {
private ClassX classx;
.....
public ClassX getClassX() {
return classx;
}
.....
}
But than, how can I call it from the fragment
?