共有設定にデータを保存したいのですが、保存中は以下の例外があります。行でSharedPreferences.Editor store = DefaultData.edit();
05-29 20:20:53.234: E/AndroidRuntime(27650): 致命的な例外: メイン 05-29 20:20:53.234: E/AndroidRuntime(27650): java.lang.NullPointerException 05-29 20:20:53.234: E/AndroidRuntime(27650): com.example.nirbhaya.DefaultDetails.onClick(DefaultDetails.java:92) 05-29 20:20:53.234: E/AndroidRuntime(27650): android.view.View.performClick(View) .java:2485) 05-29 20:20:53.234: E/AndroidRuntime(27650): android.view.View$PerformClick.run(View.java:9080) 05-29 20:20:53.234: E/AndroidRuntime (27650): android.os.Handler.handleCallback(Handler.java:587) 05-29 20:20:53.234: E/AndroidRuntime(27650): android.os.Handler.dispatchMessage(Handler.java:92) で05-29 20:20:53.234: E/AndroidRuntime(27650): android.os.Looper.loop(Looper.java:130) で 05-29 20:20:53.234: E/AndroidRuntime(27650): Android で。 app.ActivityThread.main(ActivityThread.java:3687) 05-29 20:20:53.234: E/AndroidRuntime(27650): java.lang.reflect.Method.invokeNative(ネイティブ メソッド) 05-29 20:20:53.234: E/AndroidRuntime (27650): java.lang.reflect.Method.invoke(Method.java:507) 05-29 20:20:53.234: E/AndroidRuntime(27650): com.android.internal.os.ZygoteInit$MethodAndArgsCaller で。実行 (ZygoteInit.java:867) 05-29 20:20:53.234: E/AndroidRuntime(27650): com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 05-29 20:20: 53.234: E/AndroidRuntime(27650): dalvik.system.NativeStart.main(ネイティブ メソッド) でE/AndroidRuntime(27650): com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 05-29 20:20:53.234: E/AndroidRuntime(27650): com.android.internal で.os.ZygoteInit.main (ZygoteInit.java:625) 05-29 20:20:53.234: E/AndroidRuntime (27650): dalvik.system.NativeStart.main (ネイティブ メソッド) でE/AndroidRuntime(27650): com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 05-29 20:20:53.234: E/AndroidRuntime(27650): com.android.internal で.os.ZygoteInit.main (ZygoteInit.java:625) 05-29 20:20:53.234: E/AndroidRuntime (27650): dalvik.system.NativeStart.main (ネイティブ メソッド) で
Java コード パッケージ com.example.nirbhaya;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class DefaultDetails extends Activity implements OnClickListener{
Button save,reset;
EditText dMob,dMsg,dEmail;
String defMobNo,defMsg,defEmail;
SharedPreferences DefaultData;
private static final String TAG = "DD-Activity";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.defaultdetails);
initializing();
}
private void initializing() {
// TODO Auto-generated method stub
save = (Button)findViewById(R.id.bsave1);
reset = (Button)findViewById(R.id.bReset);
dMob = (EditText)findViewById(R.id.etDefMobNo);
dMsg = (EditText)findViewById(R.id.etDefMsg);
dEmail = (EditText)findViewById(R.id.etDefEmail);
save.setOnClickListener(this);
reset.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.bsave1:
defMobNo = dMob.getText().toString();
defMsg = dMsg.getText().toString();
defEmail = dEmail.getText().toString();
Log.i(TAG,"DONE");
SharedPreferences.Editor store = DefaultData.edit();
store.putString("defMobileNo", defMobNo);
store.putString("defMessgae", defMsg);
store.putString("defEMail", defEmail);
store.commit();
Intent openStartingPoint = new Intent (getApplicationContext(), CurrentDetails.class);
startActivity(openStartingPoint);
break;
case R.id.bReset:
((EditText) findViewById(R.id.etDefMobNo)).setText("");
((EditText) findViewById(R.id.etDefEmail)).setText("");
((EditText) findViewById(R.id.etDefMsg)).setText("");
break;
}
}
}