I want to store 3000 rows in a database in my Android App. It is taking so much time. Is there any solution to reduce the time duration?
我想在我的Android App中的数据库中存储3000行。这花了很多时间。有没有减少持续时间的解决方案?
UPDATE:
public long insertContac1(String country, String city, String category)
{
// TODO Auto-generated method stub ContentValues
initialValues = new ContentValues();
initialValues.put(KEY_COUNTRY, country);
initialValues.put(KEY_CITY, city);
initialValues.put(KEY_CATEGORY, category);
return db.insert(DATABASE_TABLE1, null, initialValues);
}
1 个解决方案
#1
3
Try to wrap all in a single transaction:
尝试将所有内容包装在一个事务中:
db.beginTransaction();
try{
// your 3000 insert loop here
db.setTransactionSuccessful();
} finally {
db.endTranscation();
}
#1
3
Try to wrap all in a single transaction:
尝试将所有内容包装在一个事务中:
db.beginTransaction();
try{
// your 3000 insert loop here
db.setTransactionSuccessful();
} finally {
db.endTranscation();
}