我如何从共享偏好中检索编辑文本中的数据?

时间:2016-08-24 05:59:51

标签: android

大家好,所有人都可以告诉我,保存后我会在编辑文本中获取保存的数据,我的意思是当我保存一些文本然后我希望文本将一直出现在编辑文本中谢谢。 这是我的代码:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REMOTE_ADDR} =IP TO BLOCK GOES HERE
RewriteCond %{REMOTE_ADDR} =ANOTHER IP TO BLOCK GOES HERE
RewriteCond %{REQUEST_URI} !^/blocked
RewriteRule ^(.*)$ http://www.myhost.com/blocked [R=307,L]

RewriteCond %{REMOTE_ADDR} !=AUTHORIZED IP HERE
RewriteCond %{REQUEST_URI} !^/maintenance
RewriteRule ^(.*)$ http://www.myhost.com/maintenance [R=307,L]

ErrorDocument 400 /400.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php

2 个答案:

答案 0 :(得分:2)

inputName.setText(sharedpreferences.getString(Message, "default_value"));

答案 1 :(得分:0)

试试这个

  btnSave.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String m  = inputName.getText().toString();
                    SharedPreferences.Editor editor = sharedpreferences.edit();

                    editor.putString(Message, m);
                    editor.apply();
                    Toast.makeText(getApplicationContext(), "Thank You!", Toast.LENGTH_SHORT).show();
                    inputName.setText(m, TextView.BufferType.EDITABLE); //set the text here
                }
            });