Android之查看签名的命令和SharedPreferences以及ContentProvider使用

自己的签名查看签名信息

这里写图片描述

应用包解析查看xxx.RSA中可以看到签名信息

这里写图片描述

   /**
         * SharePreferences
         */
        SharedPreferences sp = this.getSharedPreferences("bn", Context.MODE_PRIVATE);
        String lastLoginTime=sp.getString("time",null);
        if (lastLoginTime == null) {
            lastLoginTime = "用户你好,欢迎第一次登陆";
        } else {
            lastLoginTime = "用户您好,您上次登陆的时间为:" + lastLoginTime;
        }

        SharedPreferences.Editor editor = sp.edit();
        editor.putString("time", new Date().toLocaleString());
        editor.commit();

        textView2.setText(lastLoginTime);

ContentProvider

public class SimpleActivity extends AppCompatActivity {
    ContentResolver cr;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple);
        ButterKnife.bind(this);
        cr = this.getContentResolver();//获取ContentResolver对象
        Cursor cursor = cr.query(Uri.parse("content://com.android.contacts/contacts"),
              null,
               null,
              null,
               null
        );
        StringBuilder sb = new StringBuilder();
        while (cursor.moveToNext()) {

            //获取联系人姓名

            String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

            sb.append("contactId=").append(contactId).append(",name=").append(name);
        //获取联系人手机号码
            Cursor phnones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                    null,
                    ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + contactId,
                    null,
                    null
            );
            while (phnones.moveToNext()) {
                String phone = phnones.getString(phnones.getColumnIndex("data1"));
                sb.append(",phone=").append(phone);
            }
        }
        Log.i(TAG, "onCreate: "+sb.toString());
        cursor.close();
    }

    public static final String TAG = SimpleActivity.class.getSimpleName();

}

权限


    <uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值