-1

java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.Cursor com.example.munna.homeauto.DatabaseCreation.getScene()' on a null object reference

public class Server extends Activity {

    DatabaseCreation myDb;
    int i;

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

        myDb = new DatabaseCreation(this);

    }

    public void server_check() {
        System.out.println("client");
        int j;
        int k;
        Cursor scene = myDb.getScene();//unfortunetly stops when cursor comes to this step
        while (scene.moveToNext()) {
            System.out.println("client 1");
            for (i = 0; i <= 5; i++) {
                scene.getString(i);
                System.out.println("client 2");
                // my code for server message 
            }

        }

    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • this is my requirement.i am creating a new class for generating a server message.in this class server checks databse and gets the data.everything is ok but when cursor goes to Cursor scene = myDb.getScene(); app unfortunetly stops. even i initialized database properly..i am not getting the what is the issue going on here please help me..thanq – mrunalinimunna Jan 18 '17 at 09:08

1 Answers1

0
if (sence.hasNext()) {
while (scene.moveToNext()) {
    System.out.println("client 1");
    for (i = 0; i <= 5; i++) {
        System.out.println(scene.getString(i));
       }
    }
}

Good Luck :)

clearlight
  • 12,255
  • 11
  • 57
  • 75
divyansh ingle
  • 340
  • 1
  • 9