How can I run my process of insert into database in background when my application is running? I want to run the process of insert query of the database in background.
Please can you give suggestion or a sample code?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You use a class that extends AsynTask…
Please refer this link for that.
Inside ur doInBackground() call ur method for doing insertion.
More Explanation:
Create an inner class InsertTask inside ur activity like:
Inside ur onCreate() give:
By doing this, when ur activity is called, the things written inside doInBackground() runs, there by inserting ur values.