Open Database and execute SQL - Android Database

Android examples for Database:SQL Query

Description

Open Database and execute SQL

Demo Code


//package com.book2s;

import android.content.Context;

import android.database.sqlite.SQLiteDatabase;

public class Main {
    public static void executeSQL(Context context, String sql) {
        SQLiteDatabase db = context.openOrCreateDatabase("data.db",
                context.MODE_PRIVATE, null);
        System.out.println(sql);/* ww  w  . j  a v  a 2 s .c  o m*/
        db.execSQL(sql);
        db.close();
    }
}

Related Tutorials