Kelas DBAdapter.java Aplikasi Wisata Sumut Memanfaatkan Fasilitas Google Map Pada Smartphone Berbasis Android

kita semua.\n\nSalam, Fredy S Pakpahan,dkk; alertDialog.setButtonOK, new DialogInterface.OnClickListener { public void onClickDialogInterface dialog, int which { dialog.dismiss; } }; alertDialog.show; return true; default: return super.onOptionsItemSelecteditem; } } }

2. Kelas DBAdapter.java

package com.fredy.wisata; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class DBAdapter { public static final String KEY_ID = _id; public static final String KEY_NAME = nama; public static final String KEY_KET = ket; public static final String TAG = DBAdapter; private static final String DATABASE_NAME = wisata.db; private static final String TABLE_BERSEJARAH = medan; private static final String TABLE_PANTAI = pantai; private static final String TABLE_GUNUNG = gunung; private static final String TABLE_DANAU = danau; private static final String TABLE_AIRTERJUN = airterjun; private static final int DATABASE_VERSION = 2; private static final String BERSEJARAH = create table medan _id integer primary key autoincrement, + nama text not null, ket text not null;; private static final String PANTAI = create table pantai _id integer primary key autoincrement, + nama text not null, ket text not null;; private static final String GUNUNG = create table gunung _id integer primary key autoincrement, + nama text not null, ket text not null;; private static final String DANAU = create table danau _id integer primary key autoincrement, + nama text not null, ket text not null;; private static final String AIRTERJUN = create table airterjun _id integer primary key autoincrement, + nama text not null, ket text not null;; private final Context context; private DatabaseHelper DBHelper; private SQLiteDatabase db; public DBAdapterContext ctx { this.context = ctx; DBHelper = new DatabaseHelpercontext; } Universitas Sumatera Utara private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelperContext context { supercontext, DATABASE_NAME, null, DATABASE_VERSION; } Override public void onCreateSQLiteDatabase db { try { db.execSQLBERSEJARAH; db.execSQLPANTAI; db.execSQLGUNUNG; db.execSQLDANAU; db.execSQLAIRTERJUN; } catch SQLException e { e.printStackTrace; } } Override public void onUpgradeSQLiteDatabase db, int oldVersion, int newVersion { Log.wTAG, Upgrade database dari versi + oldVersion + ke + newVersion + , yang akan menghapus semua data lama; db.execSQLDROP TABLE IF EXISTS gunung; onCreatedb; } } ---membuka database--- public DBAdapter open throws SQLException { db = DBHelper.getWritableDatabase; return this; } ---menutup database--- public void close { DBHelper.close; } menampilkan semua isi tabel database public Cursor getAllGunung { return db.queryTABLE_GUNUNG, new String[] {KEY_ID, KEY_NAME, KEY_KET}, null, null, null, null, null; } public Cursor getAllBersejarah { return db.queryTABLE_BERSEJARAH, new String[] {KEY_ID, KEY_NAME, KEY_KET}, null, null, null, null, null; } public Cursor getAllPantai { return db.queryTABLE_PANTAI, new String[] {KEY_ID, KEY_NAME, KEY_KET}, null, null, null, null, null; } public Cursor getAllDanau { return db.queryTABLE_DANAU, new String[] {KEY_ID, KEY_NAME, KEY_KET}, null, null, null, null, null; } public Cursor getAllAirTerjun { return db.queryTABLE_AIRTERJUN, new String[] {KEY_ID, KEY_NAME, KEY_KET}, null, null, null, null, null; } menampilkan sebuah isi tabel database public Cursor getSingleGunungint id throws SQLException { Universitas Sumatera Utara Cursor cursor = db.querytrue, TABLE_GUNUNG, new String[] {KEY_ID, KEY_NAME, KEY_KET}, KEY_ID + = + id, null, null, null, null, null; if cursor = null { cursor.moveToFirst; } return cursor; } public Cursor getSingleBersejarahint id throws SQLException { Cursor cursor = db.querytrue, TABLE_BERSEJARAH, new String[] {KEY_ID, KEY_NAME, KEY_KET}, KEY_ID + = + id, null, null, null, null, null; if cursor = null { cursor.moveToFirst; } return cursor; } public Cursor getSinglePantaiint id throws SQLException { Cursor cursor = db.querytrue, TABLE_PANTAI, new String[] {KEY_ID, KEY_NAME, KEY_KET}, KEY_ID + = + id, null, null, null, null, null; if cursor = null { cursor.moveToFirst; } return cursor; } public Cursor getSingleDanauint id throws SQLException { Cursor cursor = db.querytrue, TABLE_DANAU, new String[] {KEY_ID, KEY_NAME, KEY_KET}, KEY_ID + = + id, null, null, null, null, null; if cursor = null { cursor.moveToFirst; } return cursor; } public Cursor getSingleAirTerjunint id throws SQLException { Cursor cursor = db.querytrue, TABLE_AIRTERJUN, new String[] {KEY_ID, KEY_NAME, KEY_KET}, KEY_ID + = + id, null, null, null, null, null; if cursor = null { cursor.moveToFirst; } return cursor; } }

3. Kelas DashboardSetting.java