I am confused about how to operate an SQL Lite database in Android Studio. What I want is for the user to be able to continually add and search elements in a database. The confusion I have is that it seems most beginner tutorials on this topic will create a database in the MainActivity everytime the "app" is executed which leads me to believe that a new database is created from scratch rather than an old one being updated with new information (or left alone and queried). For instance in a class name DatabaseHelper I have the snippets:
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CreateTable1String);
db.execSQL(CreateTable2String);
}
... // Then methods to add, query etc.
And then in the main:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DatabaseHelper db = new DatabaseHelper(this);
... // Then do stuff with the database
}
Any insights into what I am mis-understand much appreciated.