I have a SQLite helper class like:
public class GameDbHelper extends SQLiteOpenHelper {...}
If in the android java world, I have to initialize it in the body of an activity like:
public class MainActivity extends AppCompatActivity {
...
GameDbHelper gameDBHelper;
protected void onCreate(Bundle savedInstanceState) {
...
gameDBHelper = new GameDbHelper(this);// "this" being the Context
// database: what ultimately is needed to perform CRUD
database = databaseHelper.getWritableDatabase();
}
I want to initialize this gameDBHelper in Unity side and from there call, say, database.insert(...);
From Unity documentation I learned it is possible to initialize an object to call it's methods:
void Start() {
AndroidJavaObject jo = new AndroidJavaObject("android.content.res.Configuration");
jo.Call("setToDefaults");
}
I think that perhaps I must first initialize the "gameDBHelper = new GameDbHelper(this);" in the Unity Activity:
- export the Unity project into Android Studio
- in the UnityPlayerActivity, define object and initialize it
- "somehow" call it from Unity code (defined before exporting)
A different approach:
- to export the database class as a lib from Android studio into Unity
it is more comfortable for me in Android studio, because in this project I have, Unity is not to be the launcher activity.
Please instruct me how to properly do this.