i cant seem to get it to talk to the database and don't know what to do its for a class project it gets to the emulator and then shuts down when i input the username and password please help
package com.cms.log;
import java.io.IOException;
import java.sql.*;
import android.app.Activity;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class LogActivity extends Activity {
EditText StudentID;
EditText password;
Button btnSubmit;
int count = 0;
private static SQLiteDatabase Project2;
//private DatabaseHelper mDbHelper;
private static String DB_PATH = "/log/assets/MyGrades.db";
/** Called when the activity is first created. */
public void openDataBase() throws SQLException {
// Open the database
String myPath = DB_PATH;
Project2 = SQLiteDatabase.openDatabase(myPath,
null, SQLiteDatabase.OPEN_READWRITE);
openDataBase();
}
public void close() {
Cursor mDbHelper = null;
mDbHelper.close();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
public void addListenerOnButton() {
StudentID = (EditText) findViewById(R.id.txtStudentID);
password = (EditText) findViewById(R.id.password);
btnSubmit = (Button) findViewById(R.id.btnLogin);
btnSubmit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Cursor cursor = Project2.rawQuery(
"Select Count(*) From Student Where Login = 'StudentID.getText().toString()' and Password = 'password.getText().toString()'", null);
if (cursor.moveToFirst()) {
count = cursor.getInt(0);
}
if(count > 0 ){
Toast.makeText(LogActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(LogActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}}
package com.cms.log;
import java.io.IOException;
import java.sql.*;
import android.app.Activity;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class LogActivity extends Activity {
EditText StudentID;
EditText password;
Button btnSubmit;
int count = 0;
private static SQLiteDatabase Project2;
//private DatabaseHelper mDbHelper;
private static String DB_PATH = "/log/assets/MyGrades.db";
/** Called when the activity is first created. */
public void openDataBase() throws SQLException {
// Open the database
String myPath = DB_PATH;
Project2 = SQLiteDatabase.openDatabase(myPath,
null, SQLiteDatabase.OPEN_READWRITE);
openDataBase();
}
public void close() {
Cursor mDbHelper = null;
mDbHelper.close();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
public void addListenerOnButton() {
StudentID = (EditText) findViewById(R.id.txtStudentID);
password = (EditText) findViewById(R.id.password);
btnSubmit = (Button) findViewById(R.id.btnLogin);
btnSubmit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Cursor cursor = Project2.rawQuery(
"Select Count(*) From Student Where Login = 'StudentID.getText().toString()' and Password = 'password.getText().toString()'", null);
if (cursor.moveToFirst()) {
count = cursor.getInt(0);
}
if(count > 0 ){
Toast.makeText(LogActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(LogActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}}