Questions for Context in Android. How does it work and why?
I'm trying to figure out what is the use of the context when it is being passed back into the constructor in an example below , can anyone h开发者_StackOverflow社区elp to give a more layman explanation and its possible use ? Thank you !
public static class DatabaseHelper extends SQLiteOpenHelper {
public final Context myContext;
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, 1);
this.myContext = context;
}
In Android Context contains all information about your application, and I believe it's used here to prevent your application access all databases but yours. That's why we need the Context...
精彩评论