Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.okedroid.biodatadirisqlite;
- /**
- * Created by FATHUR (Okedroid.com) on 3/28/2016.
- */
- import android.database.Cursor;
- import android.database.sqlite.SQLiteDatabase;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.Menu;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- public class LihatBiodata extends AppCompatActivity {
- protected Cursor cursor;
- DataHelper dbHelper;
- Button ton2;
- TextView text1, text2, text3, text4, text5;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_lihat_biodata);
- 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 biodata 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 = (Button) findViewById(R.id.button1);
- ton2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- finish();
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment