Expand|Select|Wrap|Line Numbers
- package com.user.registration;
- import java.util.List;
- import com.androidhive.androidsqlite.R;
- import android.app.Activity;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class Login extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.loginpage);
- final EditText editText = (EditText)findViewById(R.id.editText2);
- final EditText editText2 = (EditText)findViewById(R.id.editText1);
- Button button = (Button)findViewById(R.id.button1);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- String str1 = editText.getText().toString();
- String str2 = editText2.getText().toString();
- DatabaseHandler db = new DatabaseHandler(Login.this);
- /**
- * CRUD Operations
- * */
- // Inserting Contacts
- // Log.d("Insert: ", "Inserting ..");
- //db.getContact(3);
- System.out.print("Value of str1="+ str1);
- Log.d("Reading: ", "Reading all contacts..");
- List<Contact> contacts = db.getAllContacts();
- System.out.print("Value of str1="+ str1);
- for (Contact cn : contacts) {
- String log = "Id: "+cn.getID()+" ,Name: " + cn.getName() + " ,Phone: " + cn.getPhoneNumber();
- // Writing Contacts to log
- if(cn.getName().equals(str1) && cn.getPhoneNumber().equals(str2))
- {
- Toast.makeText(Login.this,"You login successfully",Toast.LENGTH_LONG).show();
- }
- else
- {
- Toast.makeText(Login.this,"Login Failed",Toast.LENGTH_LONG).show();
- System.out.print("Value of str1="+ str1);
- }
- Log.d("Name: ", log);
- System.out.print("Value of str1="+ str1);
- }
- }
- });
- }
- }