通讯录 实现简单查询

简单通讯录管理系统 在 PhoneManage.java 类定义一个 deletePhone(User[] users) 的方法,无返回值,该方法实现根据输入的用户名,在通讯录中删除该用户信息;在该方法中首先输出:“请输入姓名:”,然后获取键盘输入的用户姓名,再输入:“请输入手机号:”,获取键盘输入的用户手机号,最后将这些信息放入用户对象中,最后存入用户数组中。首先输出:“请输入姓名:”,然后读取键盘输入的用户名,在 users 对象中删除对应的用户信息,最后输出:“删除成功! 阅读详情

 package cn.wy;

import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
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 MainActivity extends Activity {
    private EditText edit1;
    private EditText edit2;
    private EditText edit3;
    private Button button;
    private ContentResolver contentResolver;
    private String phone;
    private String email;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        edit1 = (EditText) this.findViewById(R.id.edit1);
        edit2 = (EditText) this.findViewById(R.id.edit2);
        edit3 = (EditText) this.findViewById(R.id.edit3);
        button = (Button) this.findViewById(R.id.button);
       
        button.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View v) {
    //这是访问通讯录所有信息的固定地址
    Uri uri = Uri.parse("content://com.android.contacts/contacts");
    contentResolver = MainActivity.this.getContentResolver();
    Cursor c = contentResolver.query(uri, null, null, null, null);
    //循环、当游标指向下一个主键_id(一个主键_id就是一个存入的联系人)
    StringBuffer sb = new StringBuffer();
    String name = null;
    while(c.moveToNext()) {
     //这是查的raw_contacts表,该表提供了主键"_id"和"display_name"
     int id = c.getInt(c.getColumnIndex("_id"));
     name = c.getString(c.getColumnIndex("display_name"));
     sb.append(name);
     //查询data表下当前联系人的电话号码,条件是外键"contack_id"等于?
     uri = Uri.parse("content://com.android.contacts/data/phones");
     Cursor phoneCursor = contentResolver.query(uri, null, "contact_id=?", new String[]{String.valueOf(id)}, null);
     
     while(phoneCursor.moveToNext()) {
      phone = phoneCursor.getString(phoneCursor.getColumnIndex("data1"));
     }
     
     //查询data表下当前联系人的email,条件还是外键"contack_id"等于?
     uri = Uri.parse("content://com.android.contacts/data/emails");
     Cursor emailCursor = contentResolver.query(uri, null, "contact_id=?", new String[]{String.valueOf(id)}, null);
     while(emailCursor.moveToNext()) {
      email = emailCursor.getString(emailCursor.getColumnIndex("data1"));
     }
     
     if(edit1.getText().toString().equals(name)) {
      edit2.setText(phone);
      edit3.setText(email);
     } 
       
    }
   
    Log.i("tag",sb.toString() );
    if(sb.toString().contains(edit1.getText().toString())==false) {
     Toast.makeText(MainActivity.this, "通讯录无此记录", Toast.LENGTH_LONG).show();
    }
   }
  });
    }
}

简单通讯录 1创建一个数组;  2创建,选择人数的一个循环,向文件中输出刚刚输入的内容。  3添加,向文件文件进行添加性输出。  4查询,把文件的数据读入到数组中进行查询。  5显示,把文件的数据读入到数组中进行向屏幕进行输出。  6修改,把文件的数据读入到数组中进行条件查询到后进行修改,然后覆盖性的输出到文件中。  7删除,把文件的数据读入到数组中进行条件查询到后进行删除,然后覆盖性的输出到文件中。 8 文件的导入,在文件读入到数组中然后进行操作。 9文件的导出,数据就是在文件中进行修改的。 10退出,用for(;i==1;){}把上面的链接进行封装,只有选择退出时i的值才会改变从循环中跳出。 立即下载

相关推荐

简单通讯录简单通讯录

旨在提供Java连接Access数据库的方法。这是一个简单的通讯录小程序,<br>只有记录 姓名,手机号码,住址等信息,<br>

android 简易通讯录查询

1、通过“内容提供者”取得手机的通讯录、通话记录; 2、通讯录与通话记录关联查询,安时间先后倒序排序,在 ListView 中显示; 3、实现 EditText 的 内容变动事件,调用 sql 的 Like 查询,并返回结果; eText=(EditText)this.findViewById(R.id.editStrChang); eText.add

emal32的专栏 941

【虚拟化生态平台】虚拟化平台esxi挂载USB硬盘

虚拟化平台安装好之后,一般情况下,只有一个硬盘在工作,其他的外接硬盘(我的只有一个ssd硬盘,其他的均是usb外接,SATA接口的硬盘是否这样我暂时不清楚哈)没有在工作,但是一个硬盘明显不够我们使用的,所以我们需要去挂载外接的硬盘来扩容。...

Rubik Blog 4834

C语言——通讯录

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <Windows.h> /* 通讯录程序 */ //通过一个结构体就描述了一个联系人的情况 typedef struct PersonInfo { char name[1024]; char phone.

qq_50292797的博客 164

FeynRules的上手使用3--运行

FeynRules的运行 接上两篇,在我们正确的设定模型参数和拉氏量之后,就可以运行FeynRules来推导费曼规则。 装载文件 首先需要设定FeynRules文件所在位置,并装载FeynRules模块: $FeynRulesPath = SetDirectory[ ] << FeynRules` 接下来是装载写好的模型文件: LoadModel[ < file.fr >, < file2.fr >, … ] 模型文件后缀为".fr",可以分几块构成。模型描述可以写在

cool_bot的博客 1075

C# NX二次开发:两种过滤器设置方案的实战解析与场景适配

本文深入解析C# NX二次开发中的两种过滤器设置方案:AddFilterHandler回调与MaskTriple属性设置。通过实战案例对比其性能差异与适用场景,帮助开发者根据需求选择最优方案,提升NX插件开发效率与交互体验。特别针对BlockStyler集成场景提供专业建议,是NX二次开发者的实用指南。

weixin_33739646的博客 844

简单版通讯录

目录 一、初始准备 二、初始化通讯录 三、添加联系人 四、删除联系人 五、查找联系人 六、修改联系人 七、读写文件 八、销毁通讯录 九、全部代码 一、初始准备 首先必须得建立一个结构体,用来描述联系人的信息,如姓名、年龄、地址等等 联系人的个数肯定不止一个,所以得建立一个通讯录数组来存储,又要记录具体联系人的个数,所以再创立一个结构体用来封装,而用#define,是为了便于修改 静态版本 动态版本 用switch case语句时,使用户更加清楚每个选项代表什...

weixin_58867976的博客 3043

操作系统课程项目 OS project —— Pintos from Project 1 to Project 3

Pintos Project 陪伴我们操作系统课程大半个学期了…… 虽然做了这么长时间,个人能力有限,pintos代码,看过的可能也就看懂了一半吧,更不用说没看过的了…… 但是也找到了一些有价值的资料,整理一下,供后辈们参考…… 关于环境的问题,最好是用ubuntu 16.04 windows用户不要折腾装双系统了,特别是win10,动不动更新一下,说不定双系统就出问题了,linux...

Deserted Land 8554

简单通讯录的实现

本期来教你如何实现一个通讯录,包含增删查改,显示联系人信息,查找联系人,通讯录排序等功能,详细讲解,一看就会!

KLZUQ的博客 946

(秋招复习)一些SLAM基础

秋招复习--SLAM基础知识篇

weixin_45432823的博客 768

HyperLynx(十八)DDR(一)DDR简介和DDR的数据仿真

LVTTL电平为单端信号,而SSTL电平本质上是差分对,其实现机制是将信号与参考电平Vref组成差分对进行比较,如图所示,VIH和VIL各有一个交流参数AC和直流参数DC,信号第一次越过AC门限的时刻,作为时序计算的参考点,此后只要信号保持DC门限内,逻辑状态保持不变,这种设计减小了噪声、振铃等对于信号质量的影响。经过调整后,控制器在发送颗粒1的DQS后,延时1ns再发送颗粒2的DQS,则颗粒1在1ns后收到对齐的DQS和CLK,颗粒2在2ns后收到对齐的DQS和CLK,从而满足了时序关系。

小幽余生不加糖 7678

c语言实现通讯录查询,C语言实现简单的通讯录

实现一个通讯录;通讯录可以用来存储1000个人的信息,每个人的信息包括:姓名、性别、年龄、电话、住址提供方法:1.添加联系人信息2.删除指定联系人信息3.查找指定联系人信息4.修改指定联系人信息5.显示所有联系人信息6.清空所有联系人/***************************************** File Name : contacts.h* Creat Data : ...

weixin_39620099的博客 658

ANSYS——“There is at least 1 small equation solver pivot term”问题的解决办法

ANSYS——“There is at least 1 small equation solver pivot term”问题的解决办法

python_AI_fans的博客 1万+

java简单通讯录实现

java简单通讯录实现 功能点: 添加联系人(联系人:编号,姓名,手机号,QQ,邮箱地址)添加时需要检查手机号和邮箱地址格式是否正确,若不正确,不允许添加。 联系人查询(输入姓名或电话查询) 显示联系人列表 根据编号删除指定编号的联系人 代码实现: 联系人实体类: public class Contact { private int num; private String name; private String phoneNum; private String qq; private St

qq_40269704的博客 3250

基于STM32L4XX、HAL库的TESEO-LIV4FTR定位模块驱动程序设计

支持多星座系统:GPS、GLONASS、Galileo和北斗。支持NMEA 0183协议和ST专有协议。高灵敏度:-167dBm跟踪灵敏度。低功耗设计,适合物联网和便携设备。内置LNA和SAW滤波器。

zhusl6688的博客 237

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

用python字典编通讯录算法_Python学习-字典练习:简单通讯录

功能要求:查询联系人,输入姓名,可以查询当前通讯录里面的联系人信息,若联系人存在,则输出联系人信息,若不存在,则告知插入联系人,可以向通讯录中新建联系人,若联系人已经存在,则询问是否修改联系人信息,若不存在,则新建联系人删除联系人,可以删除联系人,若联系人不存在,则告知输入指令,退出通讯录!/usr/bin/env python3-- coding: utf-8 --@Time : 2018...

weixin_39844481的博客 896

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

利用线性表实现通讯录管理

//实现通讯录的建立、增加、删除、修改、查询等功能 // 能够实现简单的菜单交互,即可以根据用户输入的命令,选择不同的操作。 #include  #include  using namespace std; struct DataType { int ID;       //编号 char name[10]; //姓名 char ch; //性别 char p

通信狗的自我修养 6959

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

用python的字典实现简单的通讯录

性能要求: 源代码如下: print("|---欢迎进入通讯录程序---|") print("|---1:查询联系人资料 ---|") print("|---2:插入新的联系人 ---|") print("|---3:删除已有联系人 ---|") print("|---4:退出通讯录程序 ---|") print("") dict1={} while(1): n=input("请输

myloveprogrmming的博客 1万+

python——通讯录

通讯录

weixin_65482699的博客 1489

python通讯录程序

value=dict.pop(sno,'联系人不存在') #删除sno键所对应的键值数据,如果sno学号不存在反馈'联系人不存在'print(sno + ":"+dict.get(sno, '联系人不存在')) #获得指定键sno(学号)的值(姓名)print('您输入的学号在通讯录中已存在\n'+'-->>'+sno+':'+dict[sno])print('通讯录无任何联系人信息')print('|---1:查询全部联系人---|')print('|---2:查询特定联系人---|')

weixin_71961770的博客 253

Android Studio实现一个简单的通讯录

网上找的一个单页面通讯录,修改之后将添加联系人和修改/删除联系人分为两个独立页面 MainActivity package com.example.test; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.databas...

a92316的博客 7836

通讯录代码1

dict = {'2111401': '谢辉', '2111402': '闫军豪', '2111403': '朱畇达','2111404': '李金杭', '2111405': '沈恒隆'}dict = {'2011336': '王斐然', '2111301': '王晨愉', '2111302': '费文强','2111303': '高兴', '2111304': '胡佳'}print("您输入的学号在通讯录中已存在" + "-->>" + sno + ":" + dict[sno])

wyw2111424的博客 110

c语言创建通讯录不用指针,C语言《通讯录》指针实现

该楼层疑似违规已被系统折叠隐藏此楼查看此楼/*要求利用C语言面向过程的编程的思想来完成系统的设计;通讯录中的联系人包含以下信息项:姓名、手机、办公电话、家庭电话、电子邮箱、所在省市、工作单位、家庭住址,群组分类(亲属、同事、同学、朋友、其他)。系统的主要功能包括:1. 输入联系人的信息,要求:至少输入10个联系人的数据,且注意数据的多样性。2. 按姓名对联系人信息进行排序,并将排序后信息存放到一...

weixin_36214932的博客 285

python课程设计编写电子通讯录_用Python实现简单通讯录

一个简单的通讯录例子#!/usr/bin/python__author__ = 'fierce'#coding:utf-8import os #引用os模块import pickle #应用pickle模块Path='/home/Person.data' #全局变量,这里是通讯录物理路径#判断通讯录是否存在,不存在则创建空通讯录if os.path.exists(Path) == False: #...

weixin_39758696的博客 355
下一篇: ContactsProvider2 通讯录部分源码
Android_wy
博客等级 码龄16年 37粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值