MainClass.java
========================
package com.p1;
import java.util.ArrayList;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
public class MainClass extends Activity {
/** Called when the activity is first created. */
EditText descriptionEd,projectEd,expectedPayHourEd,durationEd,fixedamountEd,biddingDeadlineEd,projectdeadlineEd;
Spinner catagorySpin;
private RadioGroup radioPaymenyType;
private RadioButton radiopaymentTypeButton;
TextView mFilePathTextView;
Button mStartActivityButton;
boolean isvalid;
DbAdapter mDbHelper ;
String languageString = "";
RelativeLayout payTypePerHour,payTypeFixed;
String projectName,description="",catagory="",expectedPayHour="",duration="",fixedamount="",biddingDeadline="",projectdeadline="",paymentType="Per Hour",imagePath="";
CheckBox android1,iphone,blackberry;
ArrayList<String> language=new ArrayList<String>();
private int mYear;
private int mMonth;
private int mDay;
static final int DATE_DIALOG_ID = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
payTypePerHour=(RelativeLayout)findViewById(R.id.layoutMiddle2);
payTypeFixed=(RelativeLayout)findViewById(R.id.layoutMiddle3);
projectEd=(EditText)findViewById(R.id.project);
descriptionEd=(EditText)findViewById(R.id.description);
expectedPayHourEd=(EditText)findViewById(R.id.eph);
durationEd=(EditText)findViewById(R.id.duration);
fixedamountEd=(EditText)findViewById(R.id.fixedAmount);
biddingDeadlineEd=(EditText)findViewById(R.id.biddingDeadline);
projectdeadlineEd=(EditText)findViewById(R.id.projectDeadline);
//quantityEd.clearFocus();
/**START******************SPINNER **********************/
catagorySpin=(Spinner)findViewById(R.id.category);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
catagorySpin.setAdapter(adapter);
catagorySpin.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
catagory=parent.getItemAtPosition(pos).toString();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
/***END********************SPINNER **********************/
mFilePathTextView = (TextView)findViewById(R.id.file_path_text_view);
mStartActivityButton = (Button)findViewById(R.id.browse);
/**START*********************RADIO BUTTON **********************/
radioPaymenyType=(RadioGroup)findViewById(R.id.radioPaymentType);
radioPaymenyType.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = (RadioButton) findViewById(checkedId);
paymentType=radioButton.getText().toString();
System.out.println("paymentType=="+paymentType);
if("Per Hour".equals(paymentType)){
payTypePerHour.setVisibility(View.VISIBLE);
payTypeFixed.setVisibility(View.GONE);
}else{
payTypePerHour.setVisibility(View.GONE);
payTypeFixed.setVisibility(View.VISIBLE);
}
}
});
/***END********************RADIO BUTTON **********************/
/**START*********************CHECKBOX **********************/
android1 = (CheckBox) findViewById(R.id.check1);
android1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("android");
}
else
{
//not checked
language.remove("android");
}
}});
iphone = (CheckBox) findViewById(R.id.check2);
iphone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("iphone");
}
else
{
//not checked
language.remove("iphone");
}
}});
blackberry = (CheckBox) findViewById(R.id.check3);
blackberry.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("blackberry");
}
else
{
//not checked
language.remove("blackberry");
}
}});
/***END********************CHECKBOX **********************/
biddingDeadlineEd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
// display the current date
updateDisplay();
Button save=(Button)findViewById(R.id.save);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isvalid=true;
projectName=projectEd.getText().toString();
description=descriptionEd.getText().toString();
biddingDeadline=biddingDeadlineEd.getText().toString();
projectdeadline=projectdeadlineEd.getText().toString();
if("Per Hour".equals(paymentType)){
duration=durationEd.getText().toString();
expectedPayHour=expectedPayHourEd.getText().toString();
}else{
fixedamount=fixedamountEd.getText().toString();
}
for (String s : language)
{
languageString=languageString+ s+" " ;
}
if(isvalid){
doSave();
}
}});
}
private void updateDisplay() {
if(mMonth < 9 && mDay < 10){
this.biddingDeadlineEd.setText(
new StringBuilder()
.append("0").append(mMonth + 1).append("-")
.append("0").append(mDay).append("-")
.append(mYear)
);
}else if(mMonth < 9 && mDay > 9){
biddingDeadlineEd.setText(
new StringBuilder()
.append("0").append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear)
);
}else if(mMonth > 9 && mDay < 10){
biddingDeadlineEd.setText(
new StringBuilder()
.append(mMonth + 1).append("-")
.append("0").append(mDay).append("-")
.append(mYear)
);
}else{
biddingDeadlineEd.setText(
new StringBuilder()
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear)
);
}
}
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}
public void doSave(){
//System.out.println(language);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
System.out.println(projectName+""+description+""+catagory+""+paymentType+""+expectedPayHour+""+duration+""+fixedamount+""+biddingDeadline+""+projectdeadline+""+languageString+""+imagePath);
long m=mDbHelper.insertData(projectName,description,catagory,paymentType,expectedPayHour,duration,fixedamount,biddingDeadline,projectdeadline,languageString,imagePath);
mDbHelper.close();
System.out.println(m);
}
}
2.main.xml
===============
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:weightSum="1" android:background="#000000" android:orientation="vertical" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:id="@+id/layoutTop"
android:background="#336699"
>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:src="@+drawable/logo"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="7dp"
/>
</RelativeLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/layoutScroll"
android:layout_below="@+id/layoutTop"
android:layout_marginBottom="5dp"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:id="@+id/layoutMiddleRelative"
android:layout_below="@+id/layoutScroll">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:id="@+id/layoutMessage"
android:visibility="gone"
android:layout_below="@+id/layoutMiddleRelative">
<TextView
android:id="@+id/addMesage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text=""
android:textColor="#008000"
android:layout_centerHorizontal="true"
android:textSize="16sp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:id="@+id/layoutMiddle"
android:layout_below="@+id/layoutMessage">
<TextView
android:id="@+id/projectLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="5dp"
android:text="Project"
android:textStyle="bold"
android:textSize="16sp"
/>
<TextView
android:id="@+id/star2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/projectLable"
android:layout_toRightOf="@+id/projectLable"
android:paddingTop="10dp"
android:paddingLeft="1dp"
android:textSize="15sp"
android:textColor="#ff0000"
android:text="*"
android:textStyle="normal"
/>
<EditText android:id="@+id/project"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Project name"
android:textSize="14sp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/layoutMiddle1"
android:layout_below="@+id/layoutMiddle"
android:visibility="visible"
>
<!-- android:visibility="gone" -->
<TextView
android:id="@+id/descLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Description"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/description"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/descLable"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/catLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/descLable"
android:text="Category "
android:textStyle="bold"
android:textSize="16sp"
/>
<Spinner android:prompt="@string/planet_prompt"
android:layout_height="wrap_content"
android:id="@+id/category"
android:layout_width="200dp"
android:layout_below="@+id/description"
android:layout_alignLeft="@+id/description">
</Spinner>
<TextView
android:id="@+id/paytypeLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/catLable"
android:text="Payment Type: "
android:textStyle="bold"
android:textSize="16sp"
/>
<RadioGroup
android:id="@+id/radioPaymentType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_below="@+id/paytypeLable"
>
<RadioButton
android:id="@+id/perHour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Per Hour"
android:checked="true" />
<RadioButton
android:id="@+id/fixed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fixed Amount" />
</RadioGroup>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:id="@+id/layoutMiddle2"
android:layout_below="@+id/layoutMiddle1">
<TextView
android:id="@+id/expectedLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Exp Pay/Hour"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/eph"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/expectedLable"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/durationLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/expectedLable"
android:text="Duration "
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/duration"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_below="@+id/eph"
android:layout_alignBaseline="@+id/durationLable"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:visibility="gone"
android:id="@+id/layoutMiddle3"
android:layout_below="@+id/layoutMiddle2">
<TextView
android:id="@+id/fixedLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Fixed Amount"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/fixedAmount"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/fixedLable"
android:layout_margin="5dp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:id="@+id/layoutMiddle4"
android:layout_below="@+id/layoutMiddle3">
<TextView
android:id="@+id/biddingLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Bidding Deadline"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/biddingDeadline"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:editable="false"
android:textSize="14sp"
android:layout_alignBaseline="@+id/biddingLable"
/>
<TextView
android:id="@+id/projectDeadlineLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/biddingLable"
android:text="Proj Deadline"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/projectDeadline"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:layout_below="@+id/biddingDeadline"
android:textSize="14sp"
/>
<TextView
android:id="@+id/uploadLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/projectDeadlineLable"
android:text="Upload Attachment"
android:textStyle="bold"
android:textSize="16sp"
/>
<Button android:id="@+id/browse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Browse "
android:textSize="14sp"
android:layout_below="@+id/projectDeadlineLable"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_alignBaseline="@+id/uploadLable"/>
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Selected file"
android:textStyle="bold"
android:textColor="#fff"
android:textSize="18sp"
android:layout_below="@+id/uploadLable"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/file_path_text_view"
android:text="No file has been selected"
android:textSize="17sp"
android:layout_below="@+id/tv1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/language"
android:text="Language Known"
android:textStyle="bold"
android:textSize="16sp"
android:layout_below="@+id/file_path_text_view"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/layoutMiddle5"
android:layout_below="@+id/layoutMiddle4"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check1"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Android" />
<CheckBox
android:id="@+id/check2"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Iphone" />
<CheckBox
android:id="@+id/check3"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Blackberry" />
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:id="@+id/layoutMiddle6"
android:layout_below="@+id/layoutMiddle5">
<Button android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Submit "
android:layout_centerHorizontal="true"
android:layout_marginRight="2dp"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginLeft="2dp"
/>
<Button android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Reset "
android:layout_toLeftOf="@+id/save"
android:textSize="14sp"
android:textStyle="bold"
/>
<Button android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Back "
android:layout_toRightOf="@+id/save"
android:textSize="14sp"
android:textStyle="bold"
/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
3.Dbconnection.java
=============================================
package com.p1;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class Dbconnection extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "TEST";
private static final int DATABASE_VERSION = 1;
// Database creation sql statement
private static final String DATABASE_CREATE = "create table register (_id integer primary key autoincrement, "
+ "projectName text not null, description text,catagory text,paymentType text,expectedPayPerhour text,duration text,fixedAmount text,biddingDeadline text,projectDeadline text,language text,imagePath text);";
public Dbconnection(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Method is called during creation of the database
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}
// Method is called during an upgrade of the database, e.g. if you increase
// the database version
@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion,
int newVersion) {
Log.w(Dbconnection.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
database.execSQL("DROP TABLE IF EXISTS register");
onCreate(database);
}
}
package com.p1;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
public class DbAdapter {
private static final String DATABASE_TABLE1 = "register";
// Database fields
public static final String KEY_ROWID = "_id";
public static final String KEY_PROJECTNAME = "projectName";
public static final String KEY_DESCRIPTION = "description";
public static final String KEY_CATAGORY= "catagory";
public static final String KEY_PAYMENTTYPE = "paymentType";
public static final String KEY_EXPECTPAYPERHOUR = "expectedPayPerhour";
public static final String KEY_DURATION = "duration";
public static final String KEY_FIXEDAMOUNT = "fixedAmount";
public static final String KEY_BIDDEADLINE = "biddingDeadline";
public static final String KEY_PROJECTEADLINE = "projectDeadline";
public static final String KEY_LANGUAGE = "language";
public static final String KEY_IMAGEPATH ="imagePath";
private Context context;
private SQLiteDatabase database;
private Dbconnection dbHelper;
public DbAdapter(Context context) {
this.context = context;
}
public DbAdapter open() throws SQLException {
dbHelper = new Dbconnection(context);
database = dbHelper.getWritableDatabase();
return this;
}
public void close() {
database.close();
}
public long insertData(String pname,String desc,String catagory,String payType,String expectedPayPerHour,String duration,String amount,String bid_dead_line,String proj_dead_line,String language,String imagepath) {
ContentValues values = new ContentValues();
values.put(KEY_PROJECTNAME, pname);
values.put(KEY_DESCRIPTION, desc);
values.put(KEY_CATAGORY, catagory);
values.put(KEY_PAYMENTTYPE, payType);
values.put(KEY_EXPECTPAYPERHOUR, expectedPayPerHour);
values.put(KEY_DURATION, duration);
values.put(KEY_FIXEDAMOUNT, amount);
values.put(KEY_BIDDEADLINE, bid_dead_line);
values.put(KEY_PROJECTEADLINE, proj_dead_line);
values.put(KEY_LANGUAGE, language);
values.put(KEY_IMAGEPATH, imagepath);
return database.insert(DATABASE_TABLE1, null, values);
}
/*public Cursor fetchAllItem(String childname1) throws SQLException {
return database.rawQuery("select * from vaccineinfo where childname='"+childname1 +"'", new String[] {});
}
public Cursor fetchAlldate(String curdate) throws SQLException {
return database.rawQuery("select * from vaccineinfo where startdate='"+curdate +"'and status='Not Given'", new String[] {});
}
public Cursor fetchAllChild() throws SQLException {
return database.rawQuery("select * from childlist", new String[] {});
}
public Cursor fetchVaccine(String childname1,long rowId) throws SQLException {
Cursor mCursor =database.rawQuery("select vaccinename from vaccineinfo where childname='"+childname1 +"'and _id='"+rowId +"'", new String[] {});
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
private ContentValues createContentValues(String listname,String date1){
ContentValues values = new ContentValues();
values.put(KEY_LISTNAME, listname);
values.put(KEY_DATE, date1);
return values;
}*/
}
========================
package com.p1;
import java.util.ArrayList;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
public class MainClass extends Activity {
/** Called when the activity is first created. */
EditText descriptionEd,projectEd,expectedPayHourEd,durationEd,fixedamountEd,biddingDeadlineEd,projectdeadlineEd;
Spinner catagorySpin;
private RadioGroup radioPaymenyType;
private RadioButton radiopaymentTypeButton;
TextView mFilePathTextView;
Button mStartActivityButton;
boolean isvalid;
DbAdapter mDbHelper ;
String languageString = "";
RelativeLayout payTypePerHour,payTypeFixed;
String projectName,description="",catagory="",expectedPayHour="",duration="",fixedamount="",biddingDeadline="",projectdeadline="",paymentType="Per Hour",imagePath="";
CheckBox android1,iphone,blackberry;
ArrayList<String> language=new ArrayList<String>();
private int mYear;
private int mMonth;
private int mDay;
static final int DATE_DIALOG_ID = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
payTypePerHour=(RelativeLayout)findViewById(R.id.layoutMiddle2);
payTypeFixed=(RelativeLayout)findViewById(R.id.layoutMiddle3);
projectEd=(EditText)findViewById(R.id.project);
descriptionEd=(EditText)findViewById(R.id.description);
expectedPayHourEd=(EditText)findViewById(R.id.eph);
durationEd=(EditText)findViewById(R.id.duration);
fixedamountEd=(EditText)findViewById(R.id.fixedAmount);
biddingDeadlineEd=(EditText)findViewById(R.id.biddingDeadline);
projectdeadlineEd=(EditText)findViewById(R.id.projectDeadline);
//quantityEd.clearFocus();
/**START******************SPINNER **********************/
catagorySpin=(Spinner)findViewById(R.id.category);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
catagorySpin.setAdapter(adapter);
catagorySpin.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
catagory=parent.getItemAtPosition(pos).toString();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
/***END********************SPINNER **********************/
mFilePathTextView = (TextView)findViewById(R.id.file_path_text_view);
mStartActivityButton = (Button)findViewById(R.id.browse);
/**START*********************RADIO BUTTON **********************/
radioPaymenyType=(RadioGroup)findViewById(R.id.radioPaymentType);
radioPaymenyType.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = (RadioButton) findViewById(checkedId);
paymentType=radioButton.getText().toString();
System.out.println("paymentType=="+paymentType);
if("Per Hour".equals(paymentType)){
payTypePerHour.setVisibility(View.VISIBLE);
payTypeFixed.setVisibility(View.GONE);
}else{
payTypePerHour.setVisibility(View.GONE);
payTypeFixed.setVisibility(View.VISIBLE);
}
}
});
/***END********************RADIO BUTTON **********************/
/**START*********************CHECKBOX **********************/
android1 = (CheckBox) findViewById(R.id.check1);
android1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("android");
}
else
{
//not checked
language.remove("android");
}
}});
iphone = (CheckBox) findViewById(R.id.check2);
iphone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("iphone");
}
else
{
//not checked
language.remove("iphone");
}
}});
blackberry = (CheckBox) findViewById(R.id.check3);
blackberry.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView.isChecked()) {
//checked
language.add("blackberry");
}
else
{
//not checked
language.remove("blackberry");
}
}});
/***END********************CHECKBOX **********************/
biddingDeadlineEd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
// display the current date
updateDisplay();
Button save=(Button)findViewById(R.id.save);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isvalid=true;
projectName=projectEd.getText().toString();
description=descriptionEd.getText().toString();
biddingDeadline=biddingDeadlineEd.getText().toString();
projectdeadline=projectdeadlineEd.getText().toString();
if("Per Hour".equals(paymentType)){
duration=durationEd.getText().toString();
expectedPayHour=expectedPayHourEd.getText().toString();
}else{
fixedamount=fixedamountEd.getText().toString();
}
for (String s : language)
{
languageString=languageString+ s+" " ;
}
if(isvalid){
doSave();
}
}});
}
private void updateDisplay() {
if(mMonth < 9 && mDay < 10){
this.biddingDeadlineEd.setText(
new StringBuilder()
.append("0").append(mMonth + 1).append("-")
.append("0").append(mDay).append("-")
.append(mYear)
);
}else if(mMonth < 9 && mDay > 9){
biddingDeadlineEd.setText(
new StringBuilder()
.append("0").append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear)
);
}else if(mMonth > 9 && mDay < 10){
biddingDeadlineEd.setText(
new StringBuilder()
.append(mMonth + 1).append("-")
.append("0").append(mDay).append("-")
.append(mYear)
);
}else{
biddingDeadlineEd.setText(
new StringBuilder()
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear)
);
}
}
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}
public void doSave(){
//System.out.println(language);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
System.out.println(projectName+""+description+""+catagory+""+paymentType+""+expectedPayHour+""+duration+""+fixedamount+""+biddingDeadline+""+projectdeadline+""+languageString+""+imagePath);
long m=mDbHelper.insertData(projectName,description,catagory,paymentType,expectedPayHour,duration,fixedamount,biddingDeadline,projectdeadline,languageString,imagePath);
mDbHelper.close();
System.out.println(m);
}
}
2.main.xml
===============
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:weightSum="1" android:background="#000000" android:orientation="vertical" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:id="@+id/layoutTop"
android:background="#336699"
>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:src="@+drawable/logo"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="7dp"
/>
</RelativeLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/layoutScroll"
android:layout_below="@+id/layoutTop"
android:layout_marginBottom="5dp"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:id="@+id/layoutMiddleRelative"
android:layout_below="@+id/layoutScroll">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:id="@+id/layoutMessage"
android:visibility="gone"
android:layout_below="@+id/layoutMiddleRelative">
<TextView
android:id="@+id/addMesage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text=""
android:textColor="#008000"
android:layout_centerHorizontal="true"
android:textSize="16sp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:id="@+id/layoutMiddle"
android:layout_below="@+id/layoutMessage">
<TextView
android:id="@+id/projectLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="5dp"
android:text="Project"
android:textStyle="bold"
android:textSize="16sp"
/>
<TextView
android:id="@+id/star2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/projectLable"
android:layout_toRightOf="@+id/projectLable"
android:paddingTop="10dp"
android:paddingLeft="1dp"
android:textSize="15sp"
android:textColor="#ff0000"
android:text="*"
android:textStyle="normal"
/>
<EditText android:id="@+id/project"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Project name"
android:textSize="14sp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/layoutMiddle1"
android:layout_below="@+id/layoutMiddle"
android:visibility="visible"
>
<!-- android:visibility="gone" -->
<TextView
android:id="@+id/descLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Description"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/description"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/descLable"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/catLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/descLable"
android:text="Category "
android:textStyle="bold"
android:textSize="16sp"
/>
<Spinner android:prompt="@string/planet_prompt"
android:layout_height="wrap_content"
android:id="@+id/category"
android:layout_width="200dp"
android:layout_below="@+id/description"
android:layout_alignLeft="@+id/description">
</Spinner>
<TextView
android:id="@+id/paytypeLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/catLable"
android:text="Payment Type: "
android:textStyle="bold"
android:textSize="16sp"
/>
<RadioGroup
android:id="@+id/radioPaymentType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_below="@+id/paytypeLable"
>
<RadioButton
android:id="@+id/perHour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Per Hour"
android:checked="true" />
<RadioButton
android:id="@+id/fixed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fixed Amount" />
</RadioGroup>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:id="@+id/layoutMiddle2"
android:layout_below="@+id/layoutMiddle1">
<TextView
android:id="@+id/expectedLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Exp Pay/Hour"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/eph"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/expectedLable"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/durationLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginRight="23dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/expectedLable"
android:text="Duration "
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/duration"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_below="@+id/eph"
android:layout_alignBaseline="@+id/durationLable"/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:visibility="gone"
android:id="@+id/layoutMiddle3"
android:layout_below="@+id/layoutMiddle2">
<TextView
android:id="@+id/fixedLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Fixed Amount"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/fixedAmount"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:textSize="14sp"
android:layout_alignBaseline="@+id/fixedLable"
android:layout_margin="5dp"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:id="@+id/layoutMiddle4"
android:layout_below="@+id/layoutMiddle3">
<TextView
android:id="@+id/biddingLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:text="Bidding Deadline"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/biddingDeadline"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:editable="false"
android:textSize="14sp"
android:layout_alignBaseline="@+id/biddingLable"
/>
<TextView
android:id="@+id/projectDeadlineLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/biddingLable"
android:text="Proj Deadline"
android:textStyle="bold"
android:textSize="16sp"
/>
<EditText android:id="@+id/projectDeadline"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text=""
android:layout_below="@+id/biddingDeadline"
android:textSize="14sp"
/>
<TextView
android:id="@+id/uploadLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="5dp"
android:layout_below="@+id/projectDeadlineLable"
android:text="Upload Attachment"
android:textStyle="bold"
android:textSize="16sp"
/>
<Button android:id="@+id/browse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Browse "
android:textSize="14sp"
android:layout_below="@+id/projectDeadlineLable"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_alignBaseline="@+id/uploadLable"/>
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Selected file"
android:textStyle="bold"
android:textColor="#fff"
android:textSize="18sp"
android:layout_below="@+id/uploadLable"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/file_path_text_view"
android:text="No file has been selected"
android:textSize="17sp"
android:layout_below="@+id/tv1"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/language"
android:text="Language Known"
android:textStyle="bold"
android:textSize="16sp"
android:layout_below="@+id/file_path_text_view"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/layoutMiddle5"
android:layout_below="@+id/layoutMiddle4"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check1"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Android" />
<CheckBox
android:id="@+id/check2"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Iphone" />
<CheckBox
android:id="@+id/check3"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Blackberry" />
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:id="@+id/layoutMiddle6"
android:layout_below="@+id/layoutMiddle5">
<Button android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Submit "
android:layout_centerHorizontal="true"
android:layout_marginRight="2dp"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginLeft="2dp"
/>
<Button android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Reset "
android:layout_toLeftOf="@+id/save"
android:textSize="14sp"
android:textStyle="bold"
/>
<Button android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Back "
android:layout_toRightOf="@+id/save"
android:textSize="14sp"
android:textStyle="bold"
/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
3.Dbconnection.java
=============================================
package com.p1;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class Dbconnection extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "TEST";
private static final int DATABASE_VERSION = 1;
// Database creation sql statement
private static final String DATABASE_CREATE = "create table register (_id integer primary key autoincrement, "
+ "projectName text not null, description text,catagory text,paymentType text,expectedPayPerhour text,duration text,fixedAmount text,biddingDeadline text,projectDeadline text,language text,imagePath text);";
public Dbconnection(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Method is called during creation of the database
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(DATABASE_CREATE);
}
// Method is called during an upgrade of the database, e.g. if you increase
// the database version
@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion,
int newVersion) {
Log.w(Dbconnection.class.getName(),
"Upgrading database from version " + oldVersion + " to "
+ newVersion + ", which will destroy all old data");
database.execSQL("DROP TABLE IF EXISTS register");
onCreate(database);
}
}
4.DbAdapter.java
====================
package com.p1;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
public class DbAdapter {
private static final String DATABASE_TABLE1 = "register";
// Database fields
public static final String KEY_ROWID = "_id";
public static final String KEY_PROJECTNAME = "projectName";
public static final String KEY_DESCRIPTION = "description";
public static final String KEY_CATAGORY= "catagory";
public static final String KEY_PAYMENTTYPE = "paymentType";
public static final String KEY_EXPECTPAYPERHOUR = "expectedPayPerhour";
public static final String KEY_DURATION = "duration";
public static final String KEY_FIXEDAMOUNT = "fixedAmount";
public static final String KEY_BIDDEADLINE = "biddingDeadline";
public static final String KEY_PROJECTEADLINE = "projectDeadline";
public static final String KEY_LANGUAGE = "language";
public static final String KEY_IMAGEPATH ="imagePath";
private Context context;
private SQLiteDatabase database;
private Dbconnection dbHelper;
public DbAdapter(Context context) {
this.context = context;
}
public DbAdapter open() throws SQLException {
dbHelper = new Dbconnection(context);
database = dbHelper.getWritableDatabase();
return this;
}
public void close() {
database.close();
}
public long insertData(String pname,String desc,String catagory,String payType,String expectedPayPerHour,String duration,String amount,String bid_dead_line,String proj_dead_line,String language,String imagepath) {
ContentValues values = new ContentValues();
values.put(KEY_PROJECTNAME, pname);
values.put(KEY_DESCRIPTION, desc);
values.put(KEY_CATAGORY, catagory);
values.put(KEY_PAYMENTTYPE, payType);
values.put(KEY_EXPECTPAYPERHOUR, expectedPayPerHour);
values.put(KEY_DURATION, duration);
values.put(KEY_FIXEDAMOUNT, amount);
values.put(KEY_BIDDEADLINE, bid_dead_line);
values.put(KEY_PROJECTEADLINE, proj_dead_line);
values.put(KEY_LANGUAGE, language);
values.put(KEY_IMAGEPATH, imagepath);
return database.insert(DATABASE_TABLE1, null, values);
}
/*public Cursor fetchAllItem(String childname1) throws SQLException {
return database.rawQuery("select * from vaccineinfo where childname='"+childname1 +"'", new String[] {});
}
public Cursor fetchAlldate(String curdate) throws SQLException {
return database.rawQuery("select * from vaccineinfo where startdate='"+curdate +"'and status='Not Given'", new String[] {});
}
public Cursor fetchAllChild() throws SQLException {
return database.rawQuery("select * from childlist", new String[] {});
}
public Cursor fetchVaccine(String childname1,long rowId) throws SQLException {
Cursor mCursor =database.rawQuery("select vaccinename from vaccineinfo where childname='"+childname1 +"'and _id='"+rowId +"'", new String[] {});
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
private ContentValues createContentValues(String listname,String date1){
ContentValues values = new ContentValues();
values.put(KEY_LISTNAME, listname);
values.put(KEY_DATE, date1);
return values;
}*/
}
Tried this example but ends up with the folllowing exception at runtime.
ReplyDelete05-20 10:01:50.687: E/AndroidRuntime(300): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.registration/com.example.registration.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class
Hi Chithu
DeletePlease mail me your sample project.i will check it.The problem may occur due to some special character in xml file while you copied the code....
This comment has been removed by the author.
ReplyDeleteReally informative article.Thanks Again. Really Great.
ReplyDeleteSap Basis Administration Training Online From UK