【发布时间】:2012-01-03 03:47:59
【问题描述】:
如何获取片段中的上下文?
我需要使用我的数据库,其构造函数接受上下文,但getApplicationContext() 和FragmentClass.this 不起作用,我该怎么办?
数据库构造函数
public Database(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
【问题讨论】:
标签: java android android-fragments android-context