The way this is structured doesn't make sense.
- Java classes are always named with proper case - so it should be "AnotherTest".
- You're not actually creating a singleton, because neither your instance, nor your getInstance() are static. Also, you never access your instance via "getInstance()".
- You have a class AnotherTest, which has as a field an instance of AnotherTest, which is never, ever initialised, and which is accessed in the constructor of AnotherTest. This is just guaranteed to be null.
- You are relying on implicit state of the Application superclass, which is never, ever provided because Application is supposed to be declared in the androidmanifest.xml, where it will be constructed for you. Meanwhile, you are constructing an instance manually in your event handler, so it has none of the state you expect - but anyway, it will fall over in its own constructor because it tries to reference a null pointer to itself, as mentioned above.
Your problems are nothing to do with DB40, and everything to do with not understanding what you're doing.
It needs to be way more like:
public final class AnotherTest {
private static AnotherTest instance;
private final Context context;
private AnotherTest(Context context){
this.context = context;
// Do whatever you need to do with DB4O using *only* the supplied context here
}
public static synchronized AnotherTest getInstance(Context context){
if(instance == null){
instance = new AnotherTest(context);
}
return instance;
}
}
And in the event handler:
AnotherTest.getInstance(Context.getApplicationContext()).storePlay(newField);