hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD...

19
BAHAN DISKUSI PEMROGRAMAN MOBILE PERTEMUAN 9 Mata Kuliah : Pemrograman Mobile Dosen Pengampu : Nandang Hermanto, M.Kom Disusun Oleh : Ana Rofiqoh 15.11.0203 Probowati Setyo Rini 15.11.0220 Giat Riyadi 15.11.0286 Randi Octavian A 15.11.0273 Fandy Yuniawan 15.11.0287 Ginanjar Tri Oktavianto 15.11.0309

Transcript of hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD...

Page 1: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

BAHAN DISKUSI PEMROGRAMAN MOBILE PERTEMUAN 9

Mata Kuliah : Pemrograman Mobile

Dosen Pengampu : Nandang Hermanto, M.Kom

Disusun Oleh : Ana Rofiqoh 15.11.0203

Probowati Setyo Rini 15.11.0220

Giat Riyadi 15.11.0286

Randi Octavian A 15.11.0273

Fandy Yuniawan 15.11.0287

Ginanjar Tri Oktavianto 15.11.0309

Kelas : TI 15 D

PROGRAM STUDI TEKNIK INFORMATIKA

STMIK AMIKOM PURWOKERTO

2017

Page 2: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

BAHAN DISKUSI

Pengertian SQLite

Tipe Data Pendukung SQLite

Platform Pendukung SQLite

Produk Yang memakai SQLite

SQLiteOpenHelper

Contoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana

Page 3: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

1. PENGERTIAN SQLite

Sqlite adalah sebuah software RDBMS(Relational Database Management System) yang mendukung secara native (asli) untuk perangkat Android. Sqlite merupakan suatu sistem manajemen database ,yang mempunyai sifat ACID-compliant, yang diprogram dengan bahasa C, dan mempunyai size atau ukuran memori yang relatif kecil. Karna Sqlite termasuk database engine yang embedded (tersemat),jadi perintah Sqlite yang bisa digunakan hanya perintah-perintah standar saja.

#Sumber : http://www.okedroid.com/2016/03/cara-membuat-aplikasi-biodata-diri-sqlite-crud-android-studio.html

2. TIPE DATA PENDUKUNG SQLite

Tipe data yang didukung di SQLite : Numeric (integer, float, double) Text (char, varchar, text) DATETIME BLOB

#Sumber : http://tersesatdikuliah.blogspot.co.id/2014/06/pengertian-sqlite.html

3. PLATFORM PENDUKUNG SQLite

SQLite mendukung semua platform dan bebas memilih OS (Operating Sistem) antara lain : Windows, Linux, Mac OSX bahkan Android dan iPhone.

#Sumber : http://tersesatdikuliah.blogspot.co.id/2014/06/pengertian-sqlite.html

4. PRODUK YANG MEMAKAI SQLITE

Contoh produk-produk yang memakai SQLite : PHP Firefox Chrome iPhone AndroidBrowser firefox, Sqlite dipakai untuk menyimpan konfigurasi, bookmark dan

history website sedangkan di smartphone android, SQLite dipakai untuk menyimpan contact.

#Sumber : http://tersesatdikuliah.blogspot.co.id/2014/06/pengertian-sqlite.html

Page 4: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

5. SQLiteOpenHelper

Untuk membuat dan meng-upgrade database pada aplikasi android gunakan subclass dari class SQLiteOpenHelper. Pada class ini kamu perlu override method berikut ini untuk membuat dan meng-upgrade database.

onCreate(), dipanggil ketika database dapat diakses namun belum dibuat.

onUpdate(), dipanggil ketika aplikasi di upgrade dan nomor versi telah berubah pada kode aplikasi android. Method ini memungkinkan untuk memperbaharui(update)skema database yang ada atau drop database yang ada dan menciptakan kembali melalui method OnCreate().

Class SQLiteOpenHelper menyediakan method getReadableDatabase() dan getWritableDatabase(), untuk mendapatkan akses ke objek SQLuteDatabase.

#Sumber : https://blog.teknorial.com/mengenal-sqlite-database-pada-aplikasi-android/

6. CONTOH MEMBUAT CRUD ( CREATE, READ, UPDATE, DELETE ) SEDERHANA

a. Kita buat projek baru namanya LatSQLiteb. Lalu buat desain layoutnya

Listing coding nya :

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="anarofiqoh.latsqlite.MainActivity">

Page 5: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:orientation="horizontal">

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Name" />

<EditText android:id="@+id/editText_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:hint="Name" android:inputType="textPersonName" />

</LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:orientation="horizontal">

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:textColor="#000" android:text="Surname"/> <EditText android:id="@+id/editText_surname" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:hint="Surname" android:inputType="textPersonName" /> </LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:orientation="horizontal">

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:textColor="#000" android:text="Marks"/>

<EditText android:id="@+id/editText_marks"

Page 6: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:hint="Marks" android:inputType="textPersonName"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:orientation="horizontal">

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:textColor="#000" android:text="Id"/>

<EditText android:id="@+id/editTextId" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:hint="Id" android:inputType="textPersonName" /> </LinearLayout>

<LinearLayout android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">

<Button android:id="@+id/button_add" android:background="@color/colorAccent" android:textColor="@android:color/background_light" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Add Data" android:layout_weight="1" />

<Button android:id="@+id/button_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorAccent" android:layout_weight="1" android:text="view all" android:textColor="@android:color/background_light" /> </LinearLayout> <LinearLayout android:layout_marginTop="20dp" android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="wrap_content">

<Button

Page 7: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

android:id="@+id/button_update" android:background="@color/colorAccent" android:textColor="@android:color/background_light" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Update" android:textAppearance="@style/TextAppearance.AppCompat.Button" />

<Button android:id="@+id/button_delete" android:background="@color/colorAccent" android:textColor="@android:color/background_light" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Delete" android:textAppearance="@style/TextAppearance.AppCompat.Button" /> </LinearLayout></LinearLayout>

c. Buat file java baru namanya DataBaseHelper.java

Page 8: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah
Page 9: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

d. Isi File MainActivity.java

Page 10: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah
Page 11: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah
Page 12: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

e. Contoh output Tampilan awal

Page 13: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

Ketika diisi

Ketika di “ADD DATA”

Page 14: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

Ketika di “VIEW ALL”

Page 15: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

Ketika di “UPDATE”

Page 16: hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/BAHAN... · Web viewContoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana PENGERTIAN SQLite Sqlite adalah sebuah

Ketika di “DELETE”

#Sumber : https://juanasss.blogspot.co.id/2017/11/membuat-aplikasi-crud-sederhana-dengan.html