Tutorial Membuat Aplikasi Name Card dengan Android Studio

    Aplikasi Name Card
    Aplikasi Name Card
    Halo sobat 48😁 kali ini saya akan membagikan sebuah artikel yang berjudul Tutorial Membuat Aplikasi Name Card dengan Android Studio. Disini saya akan membahas bagaimana cara untuk membuat aplikasi Name Card atau Kartu Nama menggunakan Database SQLite. Dengan aplikasi Name Card ini kalian bisa menyimpan kontak orang yang menurut kalian penting, mulai dari: Nama, Tanggal Lahir, Telepon dan Alamat seperti layaknya Aplikasi Biodata yang pernah saya buatkan tutorialnya.

    Selain itu, disini saya menambahkan opsi untuk Update, View (Lihat Data) dan Hapus. Jika kalian ingin SOURCE CODE Aplikasi Name Card ini, silahkan download di Github saya DISINI. Tetapi jika kalian ingin tahu cara mengaplikasikannya, silahkan lanjut baca artikel ini sampai selesai😄

    Oke langsung saja tanpa basa-basi lagi kita langsung ke langkah pertama :

    1. Buat project baru di Android Studio dengan cara klik File ⇒ Project Baru. Ketika diminta untuk memilih Default Activity, pilih Empty Activity dan klik next. Untuk minSDK, disini saya set API 16 ya.

    2. Buka build.gradle dan ubah menjadi seperti ini :


    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }

    3. Buka AndroidManifest.xml dan ubah menjadi seperti ini :


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.azhar.namecard">

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    <activity android:name=".BuatKontak"
    android:label="@string/title_activity_buatbiodata">
    </activity>
    <activity android:name=".LihatKontak"
    android:label="@string/title_activity_lihatbiodata">
    </activity>
    <activity android:name=".UpdateKontak"
    android:label="@string/title_activity_updatebiodata">
    </activity>
    </application>

    </manifest>

    4. Ubah isi MainActivity.java dan activity_main.xml menjadi seperti ini :


    package com.azhar.namecard;

    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.v7.app.AppCompatActivity;
    import android.view.Menu;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;

    /**
    * Created by Azhar Rivaldi on 09/04/2019.
    */

    public class MainActivity extends AppCompatActivity {
    String[] daftar;
    ListView ListView01;
    Menu menu;
    protected Cursor cursor;
    DataHelper dbcenter;
    public static MainActivity ma;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    FloatingActionButton btn = (FloatingActionButton) findViewById(R.id.button2);
    btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
    Intent inte = new Intent(MainActivity.this, BuatKontak.class);
    startActivity(inte);
    }
    });
    ma = this;
    dbcenter = new DataHelper(this);
    RefreshList();
    }

    public void RefreshList() {
    SQLiteDatabase db = dbcenter.getReadableDatabase();
    cursor = db.rawQuery("SELECT * FROM namecard", null);
    daftar = new String[cursor.getCount()];
    cursor.moveToFirst();
    for (int cc = 0; cc < cursor.getCount(); cc++) {
    cursor.moveToPosition(cc);
    daftar[cc] = cursor.getString(1).toString();
    }
    ListView01 = (ListView) findViewById(R.id.listView1);
    ListView01.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, daftar));
    ListView01.setSelected(true);
    ListView01.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
    final String selection = daftar[arg2];
    final CharSequence[] dialogitem = {"Lihat Kontak", "Update Kontak", "Hapus Kontak"};
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle("Pilihan");
    builder.setItems(dialogitem, new
    DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int item) {
    switch (item) {
    case 0:
    Intent i = new Intent(getApplicationContext(), LihatKontak.class);
    i.putExtra("nama", selection);
    startActivity(i);
    break;
    case 1:
    Intent in = new Intent(getApplicationContext(), UpdateKontak.class);
    in.putExtra("nama", selection);
    startActivity(in);
    break;
    case 2:
    SQLiteDatabase db = dbcenter.getWritableDatabase();
    db.execSQL("delete from namecard where nama = '" + selection + "'");
    RefreshList();
    break;
    }
    }
    });
    builder.create().show();
    }
    });
    ((ArrayAdapter) ListView01.getAdapter()).notifyDataSetInvalidated();
    }
    }



    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout 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"
    tools:context=".MainActivity">

    <ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

    <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
    android:id="@+id/mBottomLayout"
    android:layout_width="fill_parent"
    android:layout_height="76.0dip"
    android:layout_gravity="bottom"
    android:orientation="vertical"
    android:visibility="visible">

    <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="76.0dip"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">

    <ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:scaleType="fitXY"
    android:src="@drawable/footer"
    android:tint="@color/colorPrimary" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/ic_add"
    app:fabSize="normal" />

    </RelativeLayout>

    </RelativeLayout>

    </FrameLayout>

    </android.support.design.widget.CoordinatorLayout>

    5. Buat BuatKontak.java dan activity_buat_kontak.xml :


    package com.azhar.namecard;

    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;

    /**
    * Created by Azhar Rivaldi on 09/04/2019.
    */

    public class BuatKontak extends AppCompatActivity {
    protected Cursor cursor;
    DataHelper dbHelper;
    FloatingActionButton ton1, ton2;
    EditText text1, text2, text3, text4, text5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_buat_kontak);

    dbHelper = new DataHelper(this);
    text1 = (EditText) findViewById(R.id.editText1);
    text2 = (EditText) findViewById(R.id.editText2);
    text3 = (EditText) findViewById(R.id.editText3);
    text4 = (EditText) findViewById(R.id.editText4);
    text5 = (EditText) findViewById(R.id.editText5);
    ton1 = (FloatingActionButton) findViewById(R.id.button1);
    ton2 = (FloatingActionButton) findViewById(R.id.button2);

    ton1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    db.execSQL("insert into namecard(no, nama, tgl, tlp, alamat) values('" +
    text1.getText().toString() + "','" +
    text2.getText().toString() + "','" +
    text3.getText().toString() + "','" +
    text4.getText().toString() + "','" +
    text5.getText().toString() + "')");
    Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
    MainActivity.ma.RefreshList();
    finish();
    }
    });
    ton2.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View arg0) {
    finish();
    }
    });
    }
    }



    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".BuatKontak">

    <EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_alignLeft="@+id/textView1"
    android:inputType="number"
    android:maxLength="10">

    <requestFocus />
    </EditText>

    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Nomor" />

    <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_alignLeft="@+id/editText1"
    android:layout_marginTop="10dp"
    android:text="Nama" />

    <EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:inputType="text"
    android:maxLength="20" />

    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText2"
    android:layout_alignLeft="@+id/editText2"
    android:layout_marginTop="10dp"
    android:text="Tanggal Lahir" />

    <EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:layout_alignLeft="@+id/textView3"
    android:inputType="date" />

    <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText3"
    android:layout_alignLeft="@+id/editText3"
    android:layout_marginTop="10dp"
    android:text="Telepon" />

    <EditText
    android:id="@+id/editText4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView4"
    android:layout_alignLeft="@+id/textView4"
    android:inputType="number" />

    <TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText4"
    android:layout_alignLeft="@+id/editText4"
    android:layout_marginTop="10dp"
    android:text="Alamat" />

    <EditText
    android:id="@+id/editText5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView5"
    android:layout_alignLeft="@+id/textView5"
    android:inputType="text"
    android:maxLength="100" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button1"
    android:src="@drawable/ic_save"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/editText5"
    android:layout_alignParentBottom="true"
    />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button2"
    android:src="@drawable/ic_back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/editText5"
    android:layout_alignRight="@+id/editText5"
    android:layout_alignParentBottom="true" />

    </RelativeLayout>

    6. Buat UpdateKontak.java dan activity_update_kontak.xml :


    package com.azhar.namecard;

    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;

    /**
    * Created by Azhar Rivaldi on 09/04/2019.
    */

    public class UpdateKontak extends AppCompatActivity {
    protected Cursor cursor;
    DataHelper dbHelper;
    FloatingActionButton ton1, ton2;
    EditText text1, text2, text3, text4, text5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_update_kontak);

    dbHelper = new DataHelper(this);
    text1 = (EditText) findViewById(R.id.editText1);
    text2 = (EditText) findViewById(R.id.editText2);
    text3 = (EditText) findViewById(R.id.editText3);
    text4 = (EditText) findViewById(R.id.editText4);
    text5 = (EditText) findViewById(R.id.editText5);
    SQLiteDatabase db = dbHelper.getReadableDatabase();
    cursor = db.rawQuery("SELECT * FROM namecard WHERE nama = '" + getIntent().getStringExtra("nama") + "'", null);
    cursor.moveToFirst();
    if (cursor.getCount() > 0) {
    cursor.moveToPosition(0);
    text1.setText(cursor.getString(0).toString());
    text2.setText(cursor.getString(1).toString());
    text3.setText(cursor.getString(2).toString());
    text4.setText(cursor.getString(3).toString());
    text5.setText(cursor.getString(4).toString());
    }
    ton1 = (FloatingActionButton) findViewById(R.id.button1);
    ton2 = (FloatingActionButton) findViewById(R.id.button2);
    ton1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    db.execSQL("update namecard set nama='" +
    text2.getText().toString() + "', tgl='" +
    text3.getText().toString() + "', tlp='" +
    text4.getText().toString() + "', alamat='" +
    text5.getText().toString() + "' where no='" +
    text1.getText().toString() + "'");
    Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
    MainActivity.ma.RefreshList();
    finish();
    }
    });
    ton2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {

    finish();
    }
    });
    }
    }



    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".UpdateKontak">

    <EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_alignLeft="@+id/textView1"
    android:inputType="number"
    android:maxLength="10">

    <requestFocus />
    </EditText>

    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="Nomor" />

    <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_alignLeft="@+id/editText1"
    android:layout_marginTop="10dp"
    android:text="Nama" />

    <EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:inputType="text"
    android:maxLength="20" />

    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText2"
    android:layout_alignLeft="@+id/editText2"
    android:layout_marginTop="10dp"
    android:text="Tanggal Lahir" />

    <EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:layout_alignLeft="@+id/textView3"
    android:inputType="date" />

    <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText3"
    android:layout_alignLeft="@+id/editText3"
    android:layout_marginTop="10dp"
    android:text="Telepon" />

    <EditText
    android:id="@+id/editText4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView4"
    android:layout_alignLeft="@+id/textView4"
    android:inputType="number" />

    <TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText4"
    android:layout_alignLeft="@+id/editText4"
    android:layout_marginTop="10dp"
    android:inputType="text"
    android:maxLength="100"
    android:text="Alamat" />

    <EditText
    android:id="@+id/editText5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView5"
    android:layout_alignLeft="@+id/textView5" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button1"
    android:src="@drawable/ic_save"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/editText5"
    android:layout_alignParentBottom="true" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button2"
    android:src="@drawable/ic_back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/editText5"
    android:layout_alignRight="@+id/editText5"
    android:layout_alignParentBottom="true" />

    </RelativeLayout>

    7. Buat LihatKontak.java dan activity_lihat_kontak.xml :


    package com.azhar.namecard;

    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.TextView;

    /**
    * Created by Azhar Rivaldi on 09/04/2019.
    */

    public class LihatKontak extends AppCompatActivity {
    protected Cursor cursor;
    DataHelper dbHelper;
    FloatingActionButton ton2;
    TextView text1, text2, text3, text4, text5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lihat_kontak);

    dbHelper = new DataHelper(this);
    text1 = (TextView) findViewById(R.id.textView1);
    text2 = (TextView) findViewById(R.id.textView2);
    text3 = (TextView) findViewById(R.id.textView3);
    text4 = (TextView) findViewById(R.id.textView4);
    text5 = (TextView) findViewById(R.id.textView5);
    SQLiteDatabase db = dbHelper.getReadableDatabase();
    cursor = db.rawQuery("SELECT * FROM namecard WHERE nama = '" + getIntent().getStringExtra("nama") + "'", null);
    cursor.moveToFirst();
    if (cursor.getCount() > 0) {
    cursor.moveToPosition(0);
    text1.setText(cursor.getString(0).toString());
    text2.setText(cursor.getString(1).toString());
    text3.setText(cursor.getString(2).toString());
    text4.setText(cursor.getString(3).toString());
    text5.setText(cursor.getString(4).toString());
    }
    ton2 = (FloatingActionButton) findViewById(R.id.button1);
    ton2.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View arg0) {
    finish();
    }
    });
    }
    }



    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".LihatKontak">

    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:layout_marginRight="104dp"
    android:text="TextView" />

    <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:gravity="center"
    android:layout_alignRight="@+id/textView1"
    android:layout_marginTop="20dp"
    android:text="TextView" />

    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="TextView" />

    <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:layout_alignLeft="@+id/textView3"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="TextView" />

    <TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView4"
    android:layout_alignRight="@+id/textView4"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="TextView" />

    <TextView
    android:id="@+id/TextView05"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView5"
    android:layout_alignLeft="@+id/TextView03"
    android:layout_alignBottom="@+id/textView5"
    android:text="Alamat" />

    <TextView
    android:id="@+id/TextView03"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView4"
    android:layout_alignLeft="@+id/TextView04"
    android:layout_alignBottom="@+id/textView4"
    android:text="Telepon" />

    <TextView
    android:id="@+id/TextView04"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignLeft="@+id/TextView02"
    android:layout_alignBottom="@+id/textView3"
    android:text="Tanggal Lahir" />

    <TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView2"
    android:layout_alignLeft="@+id/TextView01"
    android:layout_alignBottom="@+id/textView2"
    android:text="Nama" />

    <TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignParentLeft="true"
    android:text="Nomor" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/button1"
    android:src="@drawable/ic_back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" />

    </RelativeLayout>


    8. Langkah yang terakhir buat Databasenya DataHelper.java dan isinya seperti ini :


    package com.azhar.namecard;

    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;

    /**
    * Created by Azhar Rivaldi on 09/04/2019.
    */

    public class DataHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "kontak.db";
    private static final int DATABASE_VERSION = 1;

    public DataHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    String sql = "create table namecard(no integer primary key, nama text null, tgl text null, tlp text null, alamat text null);";
    Log.d("Data", "onCreate: " + sql);
    db.execSQL(sql);
    sql = "INSERT INTO namecard (no, nama, tgl, tlp, alamat) VALUES ('1', 'Azhar Rivadi', '1996-07-09', '0217819078','Jakarta');";
    db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
    }
    }

    Jika sudah selesai, silahkan kalian RUN dengan emulator bawaan Android Studio atau langsung melalui Device. Untuk hasil outpunya seperti ini:
    Aplikasi Name Card
    Aplikasi Name Card
    Aplikasi Name Card
    Aplikasi Name Card
    Kalau kalian mengikuti langkah-langkah diatas dengan baik, pasti aplikasi yang kalian buat akan berjalan sebagaimana mestinya. Namun jika mengalami Error, silahkan berikan komentar dan kita diskusikan bersama.

    Demikian informasi yang saya bagikan untuk kalian. Jangan lupa bagikan artikel ini ke teman-teman kalian agar ikut membaca Tutorial Membuat Aplikasi Name Card dengan Android Studio ini. Subscribe juga blog Rivaldi 48 ini agar kalian mendapatkan notifikasi saat Admin update artikel terbaru. Follow Instagram Admin @azhardvls_. Semoga kalian lebih nyaman dan mudah dalam mengakses Blog Rivaldi 48 dimanapun kalian berada. Terima Kasih...