Guest User

LihatBiodata.java

a guest
Mar 27th, 2016
83,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package com.okedroid.biodatadirisqlite;
  2. /**
  3.  * Created by FATHUR (Okedroid.com) on 3/28/2016.
  4.  */
  5.  
  6. import android.database.Cursor;
  7. import android.database.sqlite.SQLiteDatabase;
  8. import android.os.Bundle;
  9. import android.support.v7.app.AppCompatActivity;
  10. import android.view.Menu;
  11. import android.view.View;
  12. import android.widget.Button;
  13. import android.widget.TextView;
  14.  
  15. public class LihatBiodata extends AppCompatActivity {
  16.     protected Cursor cursor;
  17.     DataHelper dbHelper;
  18.     Button ton2;
  19.     TextView text1, text2, text3, text4, text5;
  20.  
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_lihat_biodata);
  25.  
  26.         dbHelper = new DataHelper(this);
  27.         text1 = (TextView) findViewById(R.id.textView1);
  28.         text2 = (TextView) findViewById(R.id.textView2);
  29.         text3 = (TextView) findViewById(R.id.textView3);
  30.         text4 = (TextView) findViewById(R.id.textView4);
  31.         text5 = (TextView) findViewById(R.id.textView5);
  32.         SQLiteDatabase db = dbHelper.getReadableDatabase();
  33.         cursor = db.rawQuery("SELECT * FROM biodata WHERE nama = '" +
  34.                 getIntent().getStringExtra("nama") + "'",null);
  35.         cursor.moveToFirst();
  36.         if (cursor.getCount()>0)
  37.         {
  38.             cursor.moveToPosition(0);
  39.             text1.setText(cursor.getString(0).toString());
  40.             text2.setText(cursor.getString(1).toString());
  41.             text3.setText(cursor.getString(2).toString());
  42.             text4.setText(cursor.getString(3).toString());
  43.             text5.setText(cursor.getString(4).toString());
  44.         }
  45.         ton2 = (Button) findViewById(R.id.button1);
  46.         ton2.setOnClickListener(new View.OnClickListener() {
  47.  
  48.             @Override
  49.             public void onClick(View arg0) {
  50.                 // TODO Auto-generated method stub
  51.                 finish();
  52.             }
  53.         });
  54.     }
  55.  
  56.     @Override
  57.     public boolean onCreateOptionsMenu(Menu menu) {
  58.         // Inflate the menu; this adds items to the action bar if it is present.
  59.         getMenuInflater().inflate(R.menu.main, menu);
  60.         return true;
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment