• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps app unfortunately stopped

The application is inserting the data into sqlite correctly but when i try to get it....i am getting an error "unfortunately stopped"...Can any one please help me...
MianActivity.java

package com.example.abc.sqlitedemo;

import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {

Database ob;// creating an object for the database class
EditText rno,name;
Button save;
Button get;


@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ob =new Database(this);

rno =(EditText)findViewById(R.id.editText);
name =(EditText)findViewById(R.id.editText2);
save=(Button)findViewById(R.id.save_button);
get= (Button)findViewById(R.id.get_button);
AddData();
viewData();


}
public void AddData() {

save.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
boolean isInserted =ob.insertData(rno.getText().toString(),name.getText().toString());

if (isInserted==true)
Toast.makeText(MainActivity.this, "Data Inserted", Toast.LENGTH_LONG).show();
else
Toast.makeText(MainActivity.this, "sorry", Toast.LENGTH_LONG).show();
// Retrieve the text entered from the EditText

}
}
);

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones