Hi i'm a beginner in android mobile development.
I have a question regarding sqlite(Android)...
Is there a way for me to be able to import text file onto database other than making it hardcoded..?

or if there's not,
how can i populate my database if i have a string formatted like this:

Speak Now|Taylor Swift|Released on October 25, 2010, by Big Machine Records|Song by american singer-songwriter Taylor Swift

And lastly, i'm a little bit confused about this:
Here's the scenario:
If i will create an application that needs an existing data in the database to work, where should i gonna put the adding of data into the database? Is it during the execution of the application(onCreate())?

Thanks in advance for the replies..

4 Years
Discussion Span
Last Post by peter_budo

if i will put the codes to populate my database in the onCreate() method in a class that extends SQLiteOpenHelper, does it run everytime a user open the application? when does the onCreate() method execute? is it every time the user open the application or just when the application was installed in the device and it was run for the first time?


no I said use on onResume() because onCreate is only executed when activity or fragment is started for first time, but it is not executed when coming back from pause state that mean user moved on different activity or fragment and then he decide to press back button, or perhaps your application was pause down to call or received SMS and user does return back to it and application is started from last know state and that state start with resume. Read on Activity lifecycle here

Edited by peter_budo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.