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..

Recommended Answers

All 3 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.