Here you can find the source of insertIntoTable(SQLiteDatabase database, String table, String[] data)
public static boolean insertIntoTable(SQLiteDatabase database, String table, String[] data) throws SQLiteConstraintException
//package com.java2s; import android.database.sqlite.SQLiteConstraintException; import android.database.sqlite.SQLiteDatabase; public class Main { public static boolean insertIntoTable(SQLiteDatabase database, String table, String[] data) throws SQLiteConstraintException { String values = ""; for (int i = 0; i < data.length; i++) { if (data[i].trim().length() != 0) { if (i == data.length - 1) values += quote(data[i]); else values += quote(data[i]) + ", "; } else { if (i == data.length - 1) values += "null"; else values += "null ,"; }/*from w w w. j a va2s .c o m*/ } String query = String.format("insert into %s values (%s);", table, values); database.execSQL(query); return true; } public static String quote(String s) { return "\'" + s + "\'"; } }