Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.database.sqlite.SQLiteDatabase;

public class Main {
    public static void update(SQLiteDatabase db, String table, String[] items, String[] Values, String[] key,
            String[] id) {
        String str1 = "";
        String str2 = "";
        str1 = items[0] + " = '" + Values[0] + "' ";
        str2 = key[0] + " ='" + id[0] + "' ";
        for (int i = 1; i < items.length - 1; i++) {
            str1 += ", " + items[i] + " = " + "'" + Values[i] + "' ";
        }
        for (int i = 1; i < key.length - 1; i++) {
            str2 += "and " + key[i] + " = '" + id[i] + "' ";
        }
        String sql = "update " + table + " set " + str1 + "where " + str2;
        db.execSQL(sql);
    }
}