Dunkey Dunkey - 2 years ago 54
Android Question

Android insert multiple rows to sqlite table

Hello everybody I would like to insert multiple records to my sqlite table at once,

This is what I've tried:


public void insertToOUTTRANS(ArrayList<String> arrListDocumentNumber){
ContentValues cv = new ContentValues();

for(String text : arrListDocumentNumber){
myDataBase.insert(TBL_OUTTRANS, cv, null);

But I'm getting error in this line:

myDataBase.insert(TBL_OUTTRANS, cv, null);

Error says:

The method insert(String, String, ContentValues) in the type SQLiteDatabase is not applicable for the arguments (String, ContentValues, null)


for(int i = 0; i< arrDocumentNumber.length; i++) {
ArrayList<String> arrListDocumentNumber = new ArrayList<String>();
ArrayList<String> arrListUnitOfMeasure = new ArrayList<String>();
ArrayList<String> arrListLocationCode = new ArrayList<String>();



But I'm kinda confused how to loop over the cursor to check for all items from the listview to save to my table. Any ideas? I would gladly appreciate your help. Thanks.

Answer Source

The insert methods looks like..

insert(String, String, ContentValues)

So you need to pass arguments like..

myDataBase.insert(TBL_OUTTRANS, null, cv);  

Check syntax here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download