Skip to content
Snippets Groups Projects
Commit b0a102bd authored by Niharika K's avatar Niharika K
Browse files

Merge branch 'niks'

parents 035ebc8d c88ceb6f
No related branches found
No related tags found
No related merge requests found
package com.example.chan24.smartplanner;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Niharika on 19-04-2017.
*/
public class DatabaseHelper2 extends SQLiteOpenHelper {
final static public String dbname = "ProfileDetails";
final static public String tablename ="ExtraDetails";
final static public String col1 ="Gender";
final static public String col2 ="Age";
final static public String col3= "Phone";
final static public String query ="create table "+tablename+"(Gender varchar(10),Age number(2),Phone number(11))";
public DatabaseHelper2(Context context) {
super(context, dbname, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(query);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
public boolean insertdata(String gender ,int age ,long phone )
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv= new ContentValues();
cv.put(col1,gender);
cv.put(col2,age);
cv.put(col3,phone);
long res=db.insert(tablename,null,cv);
if(res==-1)
return false;
else
return true;
}
Cursor retriving()
{
SQLiteDatabase db =this.getWritableDatabase();
Cursor c =db.rawQuery("select * from "+tablename,null);
return c;
}
}
package com.example.chan24.smartplanner;
import android.content.Intent;
import android.support.annotation.IntegerRes;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class ProfileActivity extends AppCompatActivity {
DatabaseHelper2 db=new DatabaseHelper2(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -23,4 +28,33 @@ public class ProfileActivity extends AppCompatActivity {
}
});
}
public void save(View view)
{
EditText age = (EditText)findViewById(R.id.age);
RadioGroup gender =(RadioGroup)findViewById(R.id.gender);
EditText phone = (EditText)findViewById(R.id.phone);
RadioButton selectedRadioButton;
int selectedId = gender.getCheckedRadioButtonId();
selectedRadioButton = (RadioButton)findViewById(selectedId);
//Toast.makeText(getApplicationContext(), selectedRadioButton.getText().toString()+" is selected", Toast.LENGTH_SHORT).show();
int a= Integer.parseInt(age.getText().toString());
int p = Integer.parseInt(phone.getText().toString());
boolean res =db.insertdata(selectedRadioButton.getText().toString(),a,p);
if(res) {
//Toast.makeText(this, "Inserted ", Toast.LENGTH_SHORT).show();
Intent i =new Intent(getApplicationContext(),UserArea.class);
startActivity(i);
}
}
}
......@@ -31,7 +31,7 @@ public class RegisterActivity extends AppCompatActivity {
boolean res =db.insertdata(user.getText().toString(),pass.getText().toString(),mail.getText().toString());
if(res) {
Toast.makeText(this, "Inserted ", Toast.LENGTH_SHORT).show();
//Toast.makeText(this, "Inserted ", Toast.LENGTH_SHORT).show();
Intent i =new Intent(getApplicationContext(),LoginActivity.class);
startActivity(i);
}
......
......@@ -45,7 +45,7 @@
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:layout_below="@+id/sex"
android:layout_below="@+id/gender"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:id="@+id/phone"
......@@ -64,7 +64,7 @@
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/sex"
android:id="@+id/gender"
android:orientation="horizontal"
android:layout_below="@+id/age"
android:layout_alignParentStart="true"
......@@ -93,6 +93,8 @@
android:layout_alignTop="@+id/cancel"
android:layout_alignParentEnd="true"
android:layout_marginEnd="50dp"
android:onClick="save"
android:id="@+id/save" />
</RelativeLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment