SQLite Bulk Data Load

06 May

In this post, I’ll show you how your Android app could include ability to perform bulk data load into device SQLite database.

Platform: Ai2LiveComplete

Image below shows how the app will look like.


The components in the Design Editor are shown in the below diagram:



The blocks are shown in the diagram below.

  • Screen.Initialize — used to check if first time installation. This is done by checking if any database table exists. If not, it will then invoke initDatabase procedure
  • btnDropTable.Click – used to drop mytable. It also checks to see if it exist or not. If so, it drops table (NOTE: All data will be deleted)
  • btnInitDb – once clicked, it will invoke initDatabase to re-create table and re-populate data
  • initDtabase procedure – First it creates mytable Table and then it will bulk load data in one-shot. Please note that in one call, 4 rows are inserted into database table
  • lpShowData.BeforePicking – Once this ListPicker is clicked, a query is executed to retrieve all data. Once retrieved, it will show data in a separate screen
  • lpShowTables – Once this ListPicker is clicked, it will retrieve result from SQLite.DisplayTables blocks and will then show result in the ListPicker


Image below shows data once lpShowData is clicked. The first row is the column names and subsequent rows are the data in csv format



  •  Bulk insert into SQLite database has a limit of 500 rows. If you intend to insert over 500 rows, you’ll have to break your insert statements.
  • You can easy convert a csv file into SQL CRUD (Create, Read, Update, Delete) statements using THIS online conversion tool


If your SQL data is large, you can create variance of this app that pull data from your server.

Download apk

  • Click HERE to download .apk


Mobile App Development


Posted by on May 6, 2014 in Uncategorized


11 responses to “SQLite Bulk Data Load

  1. franz

    August 23, 2017 at 10:55 am

    como optener la extencion SQLITE

  2. wilberhl

    December 16, 2014 at 4:21 pm

    Se pueden usar los comandos de sqlite3??? de acuerdo a esto??

    CSV Import

    Use the “.import” command to import CSV (comma separated value) data into an SQLite table. The “.import” command takes two arguments which are the name of the disk file from which CSV data is to be read and the name of the SQLite table into which the CSV data is to be inserted.

    Note that it is important to set the “mode” to “csv” before running the “.import” command. This is necessary to prevent the command-line shell from trying to interpret the input file text as some other format.

    sqlite> .mode csv
    sqlite> .import C:/work/somedata.csv tab1

  3. smcg814

    August 18, 2014 at 5:34 pm

    Mr. Amerkashi I have a db or csv that has 2 fields and between 2k-3k rows, I want user to search for 1 to multiple rows then do some if’s and calculation and return 1 to multiple results. It seems like Ai2LiveComplete can handle this with the sqlite. So my question is can it be done with Ai2Live and what is best way to load in all the data for search (also the db needs only to be searchable not CRUD).
    I have been playing with the MIT AI and just found yours, thank you for your efforts in making Ai even better for beginners like me.

    • M. Hossein Amerkashi

      August 18, 2014 at 8:21 pm

      Hi, Yes. You could use Ai2LiveComplete and use its SQLite component to perform CRUD operations (see HERE).

      If you have existing data that you like to import into SQLite, you can use online converter to convert your .csv to SQL statements.

      Hope this helps

  4. Nicola

    July 25, 2014 at 12:47 pm

    Good morning Mr. Amerkashi, and thank you for your application.
    i have a problem: i need to import in SQLite a .csv file with size of 1500Mb (about)
    bur the import procedure import only the first part of data…
    what is the possibility to import all data, breaking the original .csv or what?
    i’m sorry for my english…
    thank you very much!!!!

  5. mutv123

    July 16, 2014 at 9:11 pm

    Mr. Amerkashi my name is Juan I just starter using App Inventor 2 just 7 days ago. I already have an app developed that I will like to publish but I want to to add res folder with all the different subfolder for the app to be compatible with every tablet and phone. Is possible that you can help me with this ? also I will like to send you the apk of the app so you can take a look and tell me what can I make better your recommendations will be appreciated

    • M. Hossein Amerkashi

      July 16, 2014 at 10:08 pm

      res folders don’t work with AI. All images are loaded from same asset folder.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: