I have come across this question on StackOverflow but I can't use the solutions suggested. One of the most common solutions was to extend the Application class but I can't do that because the class I am in already extends another class. Is there any other way of getting the context of a class?
public class SMSReceiver extends BroadcastReceiver {
.......
.......
CreateDB dc = new CreateDB(mcontext);
dc.addBook(new Book(senderPhoneNumber,ang));
}
Basically, I need to receive a message and add the sender's number and the message to a database and I need to get the context to create an instance of the database. I am a beginner in android so it would be great if you could keep the language simple.