0

I have an Activity Med.java having the following code:

this.deleteDatabase(db.getDatabaseName());

And another activity OrderDetails.java. But in this activity I have to add the class name also:

OrderDetails.this.deleteDatabase(db.getDatabaseName());

And another activity extending Fragment:

getActivity().deleteDatabase(db.getDatabaseName());

The first two are working fine. But i want to know why in the second activity I have to add the class name. And the third fragment code, it is not working at all. Please help

Prakhar
  • 710
  • 6
  • 24

1 Answers1

0

its using context.deleteDatabase(DATABASE_NAME);

inside a fragment might be when you are calling getActivity() then getActivity() can be null at that time. refer this getActivity() returns null in Fragment function

Community
  • 1
  • 1
Praveen Sharma
  • 4,326
  • 5
  • 25
  • 45