I have a problem in initializing a new object using this in a static method. I have a database class like follow.
public class LatLogDBAdapter {
private final Context mCtx;
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
Log.w(TAG, DATABASE_CREATE);
db.execSQL(DATABASE_CREATE);
}
}
I have a static method in a another class, in that static method I like to initialize DatabaseHelper using this Context, but the error is "Can't use this in a static context".
My static method in a separate class is as follow,
public class DetailMapView extends FragmentActivity {
public static void updateLocation(String number, String LatLong){
LatLogDBAdapter dbHelper = new LatLogDBAdapter(this);
}
}
How can I do it not to have error of "Can't use this in a static context". Thanks