App crash when getting text to var in new class
<p>I've just started writing my first app.<br>
I have EditText field in which i want to get it's content (text)... <br>
I've created a new class with several fields, one of them is the target for the EditText field content.<br>
If i create a local String var and writes :(When name is the local var.)<br>
name=(order_name.getText().toString()); <br>
Everything works just fine.<br>
But when i try to use a class I've created which contains a public String field :<br>
order.setName(order_name.getText().toString());<br>
I get an FC.<br>
I also tried direct insertion from the value to the field, and when that crashed i tried using set function as shown.<br>
The class was firstly created using Eclipse new class wizard, after that i recreated it using AndroidManifest.xml wizard.<br></p>

<p><strong>Log :</strong><br></p>

<pre><code>06-01 17:06:42.104: E/AndroidRuntime(1190): FATAL EXCEPTION: main&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190): java.lang.NullPointerException&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.Sagi.MyOrders.new_order_activity$1.onClick(new_order_activity.java:46)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.view.View.performClick(View.java:2408)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.view.View$PerformClick.run(View.java:8816)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Handler.handleCallback(Handler.java:587)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Handler.dispatchMessage(Handler.java:92)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Looper.loop(Looper.java:123)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.app.ActivityThread.main(ActivityThread.java:4627)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at java.lang.reflect.Method.invokeNative(Native Method)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at java.lang.reflect.Method.invoke(Method.java:521)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)&lt;br&gt;
06-01 17:06:42.104: E/AndroidRuntime(1190):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p><strong>Thanks guys !</strong></p>

<p>Code :<br></p>

<pre><code> public class new_order_activity extends Activity {
    DatabaseHelper DBHelper;
    // LAYOUT VARS
    Button saveButton,clearButton;
    EditText order_name,link,price;
    CheckBox paid,alert;
    DatePicker date;
    // LOCAL VARS
    Order order;
    String name1;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_order_layout);
    date = (DatePicker)findViewById(R.id.order_date_field);
    alert = (CheckBox)findViewById(R.id.alert_checkbox);
    paid = (CheckBox)findViewById(R.id.paid_checkbox);
    price = (EditText)findViewById(R.id.price_field);
    order_name = (EditText)findViewById(R.id.order_name_field);
    link = (EditText)findViewById(R.id.link_field);

    saveButton = (Button) findViewById(R.id.save_button);
    clearButton = (Button) findViewById(R.id.clear_button);
    DBHelper=new DatabaseHelper(this);

    saveButton.setOnClickListener(  
        new View.OnClickListener() {
            public void onClick(View view) {
Line46:             **order.setName(order_name.getText().toString());**
                order.link=link.getText().toString();
                order.price=price.getText().toString();
                order.paid=paid.isChecked();
                order.alert=alert.isChecked();
                order.year=date.getYear();
                order.month=date.getMonth();
                order.day=date.getDayOfMonth();
                submitOrder(order);
            }
        });
</code></pre>
