There is some way for, for example, in a survey, the user to answer a series of questions, and then click on "Send survey", then click on "Surveys" and the information that you put in the previous survey appears . So on, but when the application is closed and reopened, the data is not lost. Is there any way to do it?
Currently this is the code I have:
Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT;
EditText nom = (EditText) findViewById(R.id.editText3);
EditText preg5 = (EditText) findViewById(R.id.editText2);
EditText preg4 = (EditText) findViewById(R.id.editText);
RadioButton botonun = (RadioButton) findViewById(R.id.radioButton);
RadioButton botondo = (RadioButton) findViewById(R.id.radioButton1);
RadioButton botontr = (RadioButton) findViewById(R.id.radioButton2);
RadioButton botoncu = (RadioButton) findViewById(R.id.radioButton3);
RadioButton botonci = (RadioButton) findViewById(R.id.radioButton4);
RadioButton botonse = (RadioButton) findViewById(R.id.radioButton5);
RadioButton botonsi = (RadioButton) findViewById(R.id.radioButton6);
RadioButton botonoc = (RadioButton) findViewById(R.id.radioButton7);
RadioButton botonnu = (RadioButton) findViewById(R.id.radioButton8);
RadioButton botondi = (RadioButton) findViewById(R.id.radioButton9);
RadioButton botonon = (RadioButton) findViewById(R.id.radioButton10);
RadioButton botondc = (RadioButton) findViewById(R.id.radioButton11);
String strNombre = nom.getText().toString();
String strPregCinco = preg5.getText().toString();
String strPregCuatro = preg4.getText().toString();
if(strNombre.matches("") || strPregCinco.matches("") || strPregCuatro.matches(""))
{
Toast.makeText(context,"¡Dejaste campos vacíos!",Toast.LENGTH_LONG).show();
}
else if(botonun.isChecked() == false && botondo.isChecked() == false && botontr.isChecked() == false && botoncu.isChecked() == false && botonci.isChecked() == false
&& botonse.isChecked() == false && botonsi.isChecked() == false && botonoc.isChecked() == false && botonnu.isChecked() == false && botondi.isChecked() == false
&& botonon.isChecked() == false && botondc.isChecked() == false)
{
Toast.makeText(context,"¡No marcaste algunas respuestas!",Toast.LENGTH_LONG).show();
}
else
{
Intent pas = new Intent(encuesta.this, MainActivity.class);
Toast.makeText(context,"¡Encuesta enviada!",Toast.LENGTH_LONG).show();
startActivity(pas);
}
}
});
The RadioButtons are multiple selection questions, and the EditText are open questions, so, in the mainactivity I have these buttons:
<Button
android:text="Resultados profesores"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button0"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="@string/encuesta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button4"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:elevation="0dp" />
<Button
android:text="Resultados 11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:layout_below="@+id/button0"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:text="Resultados 9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button3"
android:layout_below="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:text="Resultados 8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:layout_below="@+id/button3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
The idea of this is a school project, an application where students from several courses on mobility are surveyed, and then click on "Results 8" and you will see all the results of the 8th grade students.
The question is: How can I implement the database system in my application so that it works in that way?
Thank you!