android中读取或保存数据操作

private OnClickListener onClickListener = new OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            // TODO Auto-generated method stub
            SharedPreferences prec = MainActivity.this.getSharedPreferences("kuka", Context.MODE_PRIVATE);
            switch (v.getId())
            {
            case R.id.btnSave: // 保存数据
                Editor editor = prec.edit();
                editor.putString("name", editName.getText().toString());
                editor.putInt("age", Integer.valueOf(editAge.getText().toString()));

                editor.commit();
                Toast.makeText(MainActivity.this, "保存成功", Toast.LENGTH_LONG).show();
                break;

            case R.id.btnShow: // 取出数据
                String name = prec.getString("name", "no");
                int age = prec.getInt("age", 0);
                txtResul.setText("name:" + name + ",age:" + age);
                break;
            }
        }
    };

 

----------------------------------------------------------------------------------------------------------

C:\Users\Administrator>adb shell
error: device not found

C:\Users\Administrator>cd\

C:\>adb shell
error: device not found

C:\>cd\

C:\>adb shell
error: device not found

C:\>adb shell
error: device not found

C:\>ls
'ls' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\>adb shell
error: device not found

C:\>cd data
系统找不到指定的路径。

C:\>adb shell
error: device not found

C:\>adb shell
# cd data
cd data
# cd data
cd data
# cd com.szy.sharepreference
cd com.szy.sharepreference
# cd shared_prefs
cd shared_prefs
# cd com.shared.activity
cd com.shared.activity
cd: can't cd to com.shared.activity
# ls
ls
kuka.xml
# kuka.xml
kuka.xml
kuka.xml: not found
# cat kuka.xml
cat kuka.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name="age" value="2000666666" />
<string name="name">cool</string>
</map>
#

 

 

posted on 2012-02-05 20:09  larryle  阅读(285)  评论(0)    收藏  举报