Android: NoSuchElementException

This is one of the class of my Android project . I am getting a NoSuchElementException . When I comment the Two StringTokenizer ‘s along with the st.nextToken() & st1.nextToken() the app runs fine.
Please help
package com.example.client_nic;

import java.util.Calendar;
import java.util.StringTokenizer;

import com.example.client_nic.DataFields.fields;


import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Meeting extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.clientmeeting, container,false);  //why false still unclear
        EditText nameev= (EditText)view.findViewById(R.id.nameev);
        final String name = nameev.getText().toString();
        if(name==null){
            Toast.makeText(getActivity(), "Name cannot be Empty", Toast.LENGTH_SHORT).show();

        }

        EditText contactev= (EditText)view.findViewById(R.id.contactev);
        final String contact = contactev.getText().toString();

        EditText addressev= (EditText)view.findViewById(R.id.Addressev);
        final String address = addressev.getText().toString();

        EditText remarksev= (EditText)view.findViewById(R.id.remarksev);
        final String remarks = remarksev.getText().toString();

        EditText dateev = (EditText)view.findViewById(R.id.dateev);
        final String date = dateev.getText().toString();
        StringTokenizer st = new StringTokenizer(date, "/");


        final int day = Integer.parseInt(st.nextToken());
        final int month = Integer.parseInt(st.nextToken());
        final int year = Integer.parseInt(st.nextToken());

        EditText timeev = (EditText)view.findViewById(R.id.timeev);
        final String time = timeev.getText().toString();

        StringTokenizer st1 = new StringTokenizer(time, ":");
        final int hourOfDay  = Integer.parseInt(st1.nextToken());
        final int minute = Integer.parseInt(st1.nextToken());

        Button button = (Button)view.findViewById(R.id.button);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Calendar calender = Calendar.getInstance();
                calender.set(year, month, day, hourOfDay, minute);
                long inputtime = calender.getTimeInMillis();


                long presenttime = System.currentTimeMillis();
                if(inputtime<presenttime){
                    Toast.makeText(getActivity(), "Time has already passed", Toast.LENGTH_SHORT).show();

                }
                else{
                String insert = "INSERT INTO "+fields.table_name+" VALUES('"+name+"','"+contact+"','"+address+"','"+remarks+"','"+date+"','"+time+"' ) ";                   

                Datastore ds = new Datastore(getActivity());
                SQLiteDatabase sql = ds.getWritableDatabase();
                sql.execSQL(insert);
                }
            }
        });

        return view;


    }

}


Source: android

Leave a Reply