0

I am developing an Android App. I need to clear the data programmatically including the datastore preferences and room data when i press a button.

Rohit Jakhar
  • 1,231
  • 2
  • 12
  • 21
RussVirtuoso
  • 900
  • 1
  • 9
  • 20

1 Answers1

4

To clear the Shared Prefrences :

SharedPreferences settings = getActivity().getSharedPreferences("cda-preferences", Context.MODE_PRIVATE); 
        settings.edit().clear().commit();

and use the delete query for the database :)

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
Prachi
  • 3,584
  • 2
  • 24
  • 39