hirupmotekar.comhirupmotekar.com/wp-content/uploads/2017/12/bahan... · web viewcontoh membuat crud...
Post on 25-Apr-2018
262 Views
Preview:
TRANSCRIPT
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
BAHAN DISKUSI
Pengertian SQLite
Tipe Data Pendukung SQLite
Platform Pendukung SQLite
Produk Yang memakai SQLite
SQLiteOpenHelper
Contoh Membuat CRUD ( Create, Read, Update, Delete ) Sederhana
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
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">
<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"
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
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
d. Isi File MainActivity.java
e. Contoh output Tampilan awal
Ketika diisi
Ketika di “ADD DATA”
Ketika di “VIEW ALL”
Ketika di “UPDATE”
Ketika di “DELETE”
#Sumber : https://juanasss.blogspot.co.id/2017/11/membuat-aplikasi-crud-sederhana-dengan.html
top related