开发者

Questions for Context in Android. How does it work and why?

开发者 https://www.devze.com 2023-03-11 06:27 出处:网络
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 explanati

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消