공유 환경 설정으로 설정 클래스를 만들고 첫 번째 열린 apk에서 사용자가 기본값을 사용하고 업데이트 값으로 원하는 경우 편집 후에 편집 클래스를 만듭니다. 내 문제는 apk를 다시 열 때 환경 설정 APK가 기본 값을 표시하지 않을 때입니다. 이전 환경 설정이 표시되면이 값이 표시됩니다. 기본 설정이있는 경우 업데이트 기본 설정을 이전 저장 기본 설정으로 만듭니다 (기본값은 아니요). 나는 이것을 어떻게 창조 하는가? 현 사용자 응용 프로그램을 시작하거나 값이 존재하지 않을 때 다른 텍스트 뷰에 기본 값을 설정하기위한 귀하의 코드를 변경 기본어떻게 안드로이드 apk에서 설정 기본값 공유 환경 설정?
String strValue ="http://www.power7.net/LEDstate.txt";//default value
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ioweb_bt);
/* SharedPreferences preferences = getSharedPreferences("dataioweb" , MODE_PRIVATE);
String strValue = preferences.getString("Url","");
text = (TextView) findViewById(R.id.textUrl);
text.setText(strValue);
*/
edittxtUrl = (EditText)findViewById(R.id.txtUrl);
edittxtUrl.setText(strValue);
}
public void Save(View view) {
SharedPreferences preferences = getSharedPreferences("dataioweb" , MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); // Put the values from the UI
edittxtUrl = (EditText)findViewById(R.id.txtUrl);
String strUrl = edittxtUrl.getText().toString();
editor.putString("Url", strUrl); // value to store
// Commit to storage
editor.commit();