How to add data from User into Table

I am creating a Restaurant app . In which the user will provide date , time , and a integer total three inputs . And I want to store these three inputs in a table in Backendless console . Can some help me how to do this.

main.xml

<?xml version=“1.0” encoding=“utf-8”?>

</TextView>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Book Your Table"
    android:id="@+id/heading"
    android:layout_gravity="center_horizontal" />

<TextView android:textColor="#fff" android:textSize="20dp"
    android:layout_height="wrap_content" android:id="@+id/textView2"
    android:text="Date and Time Picker Dialog" android:layout_width="wrap_content"
    android:layout_gravity="center_horizontal" android:paddingTop="5dp"
    android:paddingBottom="25dp">&lt;/TextView&gt;
<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:id="@+id/linearLayout1">
    <EditText android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="1"
        android:id="@+id/txtDate">
        &lt;requestFocus&gt;&lt;/requestFocus&gt;
    &lt;/EditText&gt;
    <Button android:layout_height="wrap_content"
        android:layout_weight="0" android:id="@+id/btnCalendar" android:text="Calendar"
        android:layout_width="100dp">&lt;/Button&gt;
&lt;/LinearLayout&gt;
<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:id="@+id/linearLayout2">
    <EditText android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="1"
        android:id="@+id/txtTime">
        &lt;requestFocus&gt;&lt;/requestFocus&gt;
    &lt;/EditText&gt;
    <Button android:layout_height="wrap_content"
        android:layout_weight="0" android:id="@+id/btnTimePicker"
        android:text="Time Picker" android:layout_width="100dp">&lt;/Button&gt;
&lt;/LinearLayout&gt;

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Guests number"
    android:id="@+id/guestNumber" />

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="number"
    android:ems="10"
    android:id="@+id/editGuest" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Submit"
    android:id="@+id/submitBtn"
    android:layout_gravity="center_horizontal"
    android:textColor="#FF4081"
    android:textSize="25px" />

</LinearLayout>
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TimePicker;

import com.backendless.Backendless;
import com.backendless.samples.restaurant.utility.BackendSettings;

Pulse7DatePickerDialogActivity.java

import java.util.Calendar;

public class Pulse7DatePickerDialogActivity extends Activity implements
OnClickListener {

// Widget GUI
Button btnCalendar, btnTimePicker,submit;
EditText txtDate, txtTime,guests;

// Variable for storing current date and time
private int mYear, mMonth, mDay, mHour, mMinute;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Backendless.initApp( this, BackendSettings.APPLICATION_ID, BackendSettings.ANDROID_SECRET_KEY, BackendSettings.VERSION );
    submit = (Button) findViewById(R.id.submitBtn);

    View.OnClickListener submitOrderButtonListener= createSubmitButtonListener();
    submit.setOnClickListener(submitOrderButtonListener);



    btnCalendar = (Button) findViewById(R.id.btnCalendar);
    btnTimePicker = (Button) findViewById(R.id.btnTimePicker);


    txtDate = (EditText) findViewById(R.id.txtDate);
    txtTime = (EditText) findViewById(R.id.txtTime);
    guests=(EditText) findViewById(R.id.editGuest);

    btnCalendar.setOnClickListener(this);
    btnTimePicker.setOnClickListener(this);


}

@Override
public void onClick(View v) {

    if (v == btnCalendar) {

        // Process to get Current Date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        // Launch Date Picker Dialog
        DatePickerDialog dpd = new DatePickerDialog(this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        // Display Selected date in textbox
                        txtDate.setText(dayOfMonth + "-"
                                + (monthOfYear + 1) + "-" + year);

                    }
                }, mYear, mMonth, mDay);
        dpd.show();
    }
    if (v == btnTimePicker) {

        // Process to get Current Time
        final Calendar c = Calendar.getInstance();
        mHour = c.get(Calendar.HOUR_OF_DAY);
        mMinute = c.get(Calendar.MINUTE);

        // Launch Time Picker Dialog
        TimePickerDialog tpd = new TimePickerDialog(this,
                new TimePickerDialog.OnTimeSetListener() {

                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay,
                                          int minute) {
                        // Display Selected time in textbox
                        txtTime.setText(hourOfDay + ":" + minute);
                    }
                }, mHour, mMinute, false);
        tpd.show();
    }
}

}

Hi, Prasanth.

You can use our Data samples to get started with building your application with Backendless.
Download samples as shown on screenshot.
Also consult our Data Service documentation for Android.
http://image.prntscr.com/image/0a7ac7088fed4c5c8ba960159a4c8a44.png</img>

I have tried something after seeing the documentation but it did not worked i dont know why can u please help me . I am creating a date and time picker and a integer. I have created a table by name TableClass in Backendless console . There are two values in it one is int = guests , DATETIME = time , .

I want to add the date and time from my app to the DateTime coloumn in table and the integer into guests column .
Can someone tell me where Am I doing Wrong

my java Class files are

TableClass.Java

public class TableClass {

private EditText guests;
private EditText time;

public EditText getGuests(){
    return guests;

}
public void setGuests(EditText guests){
    this.guests=guests;

}

public EditText getTime(){
    return time;
}
public void setTime(EditText time){
    this.time=time;
}

}

Pulse7DatePickerDialogActivity.Java
public class Pulse7DatePickerDialogActivity extends Activity implements
OnClickListener {

// Widget GUI
Button btnCalendar, btnTimePicker,submit;
EditText txtDate, txtTime,guests1;

// Variable for storing current date and time
private int mYear, mMonth, mDay, mHour, mMinute;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Backendless.initApp( this, BackendSettings.APPLICATION_ID, BackendSettings.ANDROID_SECRET_KEY, BackendSettings.VERSION );
    submit = (Button) findViewById(R.id.submitBtn);






    btnCalendar = (Button) findViewById(R.id.btnCalendar);
    btnTimePicker = (Button) findViewById(R.id.btnTimePicker);


    txtDate = (EditText) findViewById(R.id.txtDate);
    txtTime = (EditText) findViewById(R.id.txtTime);
    guests1=(EditText) findViewById(R.id.editGuest);

    btnCalendar.setOnClickListener(this);
    btnTimePicker.setOnClickListener(this);

    submit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            saveTable(guests1,txtTime);
            Intent intent=new Intent(Pulse7DatePickerDialogActivity.this,RestaurantListingActivity.class);
        }
    });




}

public void saveTable(final EditText guests1, final EditText txtTime){

    TableClass tableClass=new TableClass();
    tableClass.setGuests(guests1);
    tableClass.setTime(txtTime);

   // TableClass savedTableOrder=Backendless.Persistence.save( tableClass );
    Backendless.Persistence.save(  tableClass, new AsyncCallback&lt;TableClass&gt;() {
        public void handleResponse( TableClass response )
        {
            response.setGuests(guests1);
            response.setTime(txtTime);


            // new Contact instance has been saved
        }

        public void handleFault( BackendlessFault fault )
        {
            // an error has occurred, the error code can be retrieved with fault.getCode()
        }
    });
}


@Override
public void onClick(View v) {

    if (v == btnCalendar) {

        // Process to get Current Date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        // Launch Date Picker Dialog
        DatePickerDialog dpd = new DatePickerDialog(this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        // Display Selected date in textbox
                        txtDate.setText(dayOfMonth + "-"
                                + (monthOfYear + 1) + "-" + year);

                    }
                }, mYear, mMonth, mDay);
        dpd.show();
    }
    if (v == btnTimePicker) {

        // Process to get Current Time
        final Calendar c = Calendar.getInstance();
        mHour = c.get(Calendar.HOUR_OF_DAY);
        mMinute = c.get(Calendar.MINUTE);

        // Launch Time Picker Dialog
        TimePickerDialog tpd = new TimePickerDialog(this,
                new TimePickerDialog.OnTimeSetListener() {

                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay,
                                          int minute) {
                        // Display Selected time in textbox
                        txtTime.setText(hourOfDay + ":" + minute);
                    }
                }, mHour, mMinute, false);
        tpd.show();
    }
}

}

I have tried something after seeing the documentation but it did not worked i dont know why can u please help me . I am creating a date and time picker and a integer. I have created a table by name TableClass in Backendless console . There are two values in it one is int = guests , DATETIME = time , .

I want to add the date and time from my app to the DateTime coloumn in table and the integer into guests column .
Can someone tell me where Am I doing Wrong

my java Class files are

TableClass.Java

public class TableClass {

private EditText guests;
private EditText time;

public EditText getGuests(){
return guests;

}
public void setGuests(EditText guests){
this.guests=guests;

}

public EditText getTime(){
return time;
}
public void setTime(EditText time){
this.time=time;
}
}

Pulse7DatePickerDialogActivity.Java
public class Pulse7DatePickerDialogActivity extends Activity implements
OnClickListener {

// Widget GUI
Button btnCalendar, btnTimePicker,submit;
EditText txtDate, txtTime,guests1;

// Variable for storing current date and time
private int mYear, mMonth, mDay, mHour, mMinute;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Backendless.initApp( this, BackendSettings.APPLICATION_ID, BackendSettings.ANDROID_SECRET_KEY, BackendSettings.VERSION );
submit = (Button) findViewById(R.id.submitBtn);

btnCalendar = (Button) findViewById(R.id.btnCalendar);
btnTimePicker = (Button) findViewById(R.id.btnTimePicker);

txtDate = (EditText) findViewById(R.id.txtDate);
txtTime = (EditText) findViewById(R.id.txtTime);
guests1=(EditText) findViewById(R.id.editGuest);

btnCalendar.setOnClickListener(this);
btnTimePicker.setOnClickListener(this);

submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
saveTable(guests1,txtTime);
Intent intent=new Intent(Pulse7DatePickerDialogActivity.this,RestaurantListingActivity.class);
}
});

}

public void saveTable(final EditText guests1, final EditText txtTime){

TableClass tableClass=new TableClass();
tableClass.setGuests(guests1);
tableClass.setTime(txtTime);

// TableClass savedTableOrder=Backendless.Persistence.save( tableClass );
Backendless.Persistence.save( tableClass, new AsyncCallback<TableClass>() {
public void handleResponse( TableClass response )
{
response.setGuests(guests1);
response.setTime(txtTime);

// new Contact instance has been saved
}

public void handleFault( BackendlessFault fault )
{
// an error has occurred, the error code can be retrieved with fault.getCode()
}
});
}

@Override
public void onClick(View v) {

if (v == btnCalendar) {

// Process to get Current Date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {

@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// Display Selected date in textbox
txtDate.setText(dayOfMonth + “-”

  • (monthOfYear + 1) + “-” + year);

}
}, mYear, mMonth, mDay);
dpd.show();
}
if (v == btnTimePicker) {

// Process to get Current Time
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);

// Launch Time Picker Dialog
TimePickerDialog tpd = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {

@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
// Display Selected time in textbox
txtTime.setText(hourOfDay + “:” + minute);
}
}, mHour, mMinute, false);
tpd.show();
}
}
}

Hi, Prasanth!

According to our Support Policy we cannot debug your code for you (since we do not have enough resources for this.)
Instead we give our users sample examples that can help them get started with Backendless + provide our documentation so that they can get deeper in the topics they need.
Thanks for understanding.