1

I am developing an application. In this I am using the sqlite database.

First time I am taking the data from assets and then inserting into database. From second time onwards I am taking data from the Database.

But first time my application is very slow. Finally my application is too slow. My question is, will the application become slow when we use sqlite in our app? and what we can do for this type of issue.

Please give me some suggestions.

2
  • A whole bunch of factors are involved in the performance of a database application. It is very difficult to help you without knowing something more specific such as, which query is slow, how much data is involved, what tables and indexes are involved, etc. Nov 2, 2010 at 13:19
  • Actually first i am getting the data from assets as xml as different categeories nearly those are 13 and each category contains nearly 30 items and add these categories as different tables in db
    – Pinki
    Nov 2, 2010 at 13:22

2 Answers 2

1

It is possible the parser you are using for reading the XML file is working very slowly - but this shouldn't be the case as I can process a XML file with 7000 entries, with 3 entities each in around 12 seconds adding each entry to the DB.

If it is causing you problems with a Force Close / Wait dialog, run the first import in a seperate thread, not the UI one.

Another solution would be for you to load the data into a DB on the emulator, get the sqlite file from the applicaiton directory and package that with your application, then its just a question of moving the file from the asset folder to the DB folder:

Database Populating Solution for large DB's, but you could simplify the process if the DB is less than 1mb in the asset folder.

1

Another thing I did think of I forgot to mention, when you are doing the initial inserts, are you inseting each record as you find it? If so you may find it faster to use a transaction:

db2.beginTransaction();
try 
{
    // Perform logic loop and perform each insert:



    db2.setTransactionSuccessful();
}
finally 
{
    db2.endTransaction();
}
1
  • This is very true - using the default behaviour of a transaction per query is so much slower than wrapping it in a single transaction.
    – Nick
    Nov 3, 2010 at 9:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.