lundi 23 mars 2015

How to import external sqlite database for the login form?

i need to know that whats wrong with my code? I had used the code from here itself of sqlite database file tobe imported exrernally & used it as database for login of my application.


Login_Activity:



public class Login_Activity extends Activity{

Intent i=null;
ImageView im=null;
EditText ed1,ed4,ed5;
boolean flag=false;
SQLiteDatabase db=null;


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


ed1=(EditText)findViewById(R.id.loginid);
ed4=(EditText)findViewById(R.id.password2);

db=openOrCreateDatabase("mydatabase", MODE_PRIVATE, null);
}
public void action(View v)
{
switch(v.getId())
{
case R.id.start:
String loginid=tv1.getText().toString();
String password=tv4.getText().toString();

if(loginid==null||loginid==""||loginid.length()<4)
{
show("Please Enter Correct id.");
}
else if(password==null||password==""||password.length()<6)
{
show("Please Enter Correct Password.");
}
else
{
Cursor c=db.rawQuery("select * from trial where loginid='"+loginid+"' and password='"+password+"'",null);
c.moveToFirst();
if(c.getCount()>0 && loginid.startsWith("M"))
{
i=new Intent(this,Welcome_Manager.class);
startActivityForResult(i,500);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
db.close();
finish();
}

Aucun commentaire:

Enregistrer un commentaire