I am doing a project where i need to retrieve data from sqlite database but it is not happening kindly help me through out.
my login code
package com.example.pallavi.myproject;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
public class Login extends Activity{
Intent i=null;
EditText tv1,tv4;
boolean flag=false;
SQLiteDatabase db=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
tv1 = (EditText) findViewById(R.id.phone2);
tv4 = (EditText) findViewById(R.id.password2);
db = openOrCreateDatabase("mydb", MODE_PRIVATE, null);
}
public void action(View v)
{
String mobile_no=tv1.getText().toString();
String password=tv4.getText().toString();
/* if(mobile_no==null||mobile_no=="")
{
show("Please Enter Correct mobile number.");
}
else if(password==null||password=="")
{
show("Please Enter Correct Password.");
}
else*/
{
show("Query is not executing");
String[] args={"null"};
Cursor c=db.rawQuery("select * from login where mobile_no='"+mobile_no+"'",args);
c.moveToFirst();
show("not going inside");
if(c.getCount()>0)
{
show("Success fully login");
i=new Intent(this,post.class);
db.close();
finish();
}
else
show("Wrong Password or Mobile number.");
}
}
public void acc(View v)
{
if (v.getId()==R.id.button)
{
Intent i=new Intent(Login.this,MainActivity.class);
startActivity(i);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
public void show(String str)
{
Toast.makeText(this, str, Toast.LENGTH_LONG).show();
}
}
kindly check through it. I am trying to retreive data from db and check but it is not performing the operation.
Aucun commentaire:
Enregistrer un commentaire