How to connect my android app to database with MS Access
<p>I want to connect my android app to a MS Access database and the java code is provided below.....but when I run it shows a message like "unfortunately app is closed" although it contains no error......and also the file name of database is 'VotingData' and Table name is 'Memeber'...</p>

<p>Is there any solution for this.</p>

<p>Thanks in advance.......</p>

<pre><code>import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.sql.*;

public class Database extends Activity implements OnClickListener{

Connection con;
Statement stmt;
ResultSet rs;
String name,query;
int age;
EditText t1;
TextView tv1;
Button click;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_database);

    t1=(EditText) findViewById(R.id.t1);
    tv1=(TextView) findViewById(R.id.tv1);
    click=(Button) findViewById(R.id.click);

    click.setOnClickListener((android.view.View.OnClickListener) this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_database, menu);
    return true;
}

public void showData()
{
        try
        {
                t1.setHint("Enter the Member name");
                name=t1.getText().toString();

                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con = DriverManager.getConnection("jdbc:odbc:VotingData","","");
                stmt = con.createStatement();
                query="select * from Members where mem_name ='"+name+"'   ";
                rs = stmt.executeQuery(query);
                while(rs.next())
                    {
                        age=rs.getInt("mem_age");
                        if(age&gt;=18)
                        {
                            tv1.setText("ELIGIBLE FOR VOTING.");
                        }
                        else
                        {
                            tv1.setText("NOT ELIGIBLE FOR VOTING.");
                        }
                    }
                con.close();
                stmt.close();
        }catch(Exception e)
            {
                    System.out.println(e);
            }
}

@Override
public void onClick(View v) {
    if(v.getId() == R.id.click)
    {
        showData();
    }
}
}
</code></pre>
