Witam,
Mam pewną klasę wewnętrzną w kodzie Androidowym:
private static class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context, String name, CursorFactory factory, int version) {
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DB_CREATE_TODO_TABLE);
Log.d(DEBUG_TAG, "Database creating..");
Log.d(DEBUG_TAG, "Table " + DB_TODO_TABLE + " ver." + DB_VERSION + " created");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(DROP_TODO_TABLE);
Log.d(DEBUG_TAG, "Database updating...");
Log.d(DEBUG_TAG, "Table " + DB_TODO_TABLE + " updated from ver." + oldVersion + " to ver." + newVersion);
Log.d(DEBUG_TAG, "All data is lost");
onCreate(db);
}
}
Klasa ta jest statyczna i wewnętrzna.
Pytanie:
Po co tworzyć klasy statyczne? Czy zabraniamy w ten sposób tworzenia obiektów tej klasy, wszystkie metody tej klasy automatycznie stają się statyczne i mogą być wywoływane niezależnie od obiektu (bo nie działają na obiekcie, łączy je tylko wspólna przestrzeń nazw)?