I do not understand a bit the moment in creating a database, help.

Suppose we have a DBHelper class inherited from SQLiteOpenHelper . When the database is being launched through the DBHelper(Context context) constructor, and the call to it is super(context, "myDatabase", null, 1) , what happens when there is no database? As I understand it, the onCreate method is onCreate , and in it the execSQL command (it indicates the created table with columns), but this command already indicates the table in the database. This means that the database was created earlier, but when and how? Explain, please.

My guess is: it was created when I called the super constructor, with the name and version number passed to it in the arguments, but I’m not sure about that, because I haven’t heard about it anywhere.

Closed due to the fact that the issue is too general for the participants Stranger in the Q , aleksandr barakin , Vladimir Glinskikh , MAXOPKA , Peter Olson 28 Aug '15 at 1:16 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Try to write more detailed questions. Explain exactly what you see the problem, how to reproduce it, what you want to get as a result, etc. - Nicolas Chabanovsky
  • If you write in more detail, there will be another question, you have to throw off a bunch of code, and so on. At the moment, you should not do so. - user189127
  • It seems to be written here that the designer creates a new database, and in the case of specifying the name, it also contains a file on the media. - pavlofff

1 answer 1

Yes that's right. When onCreate is onCreate , the database itself already exists.

This is clearly not written, because SQLiteOpenHelper created in order not to think about the process of creating a database. Created a SQLiteOpenHelper object, the database is ready.