Bulk Insertion on Android device

后端 未结 5 827
刺人心
刺人心 2020-11-28 02:40

I want to bulk insert about 700 records into the Android database on my next upgrade. What\'s the most efficient way to do this? From various posts, I know that if I use <

5条回答
  •  无人及你
    2020-11-28 03:06

    Well, my solution for this it kind of weird but works fine... I compile a large sum of data and insert it in one go (bulk insert?)

    I use the db.execSQL(Query) command and I build the "Query" with the following statement...

    INSERT INTO yourtable SELECT * FROM (
        SELECT 'data1','data2'.... UNION
        SELECT 'data1','data2'.... UNION
        SELECT 'data1','data2'.... UNION
        .
        .
        .
        SELECT 'data1','data2'....
    )
    

    The only problem is the building of the query which can be kind of messy. I hope it helps

提交回复
热议问题