In Activity B
where you want to move to FragmentB
Of ActivityA
write
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.replace(R.id.content_frame, new FragmentB; );
ft.commit();
Where R.id.content_frame
is layout id For your Activity A
and for doing database
with
button
in action bar
write code in Activity A
and FragmentB
in onCreateOptionsMenu
and in FragmentB
write
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
}
Still You are not getting the solution than please post your code ..