从 Android 的 SIM 卡读取/写入
我一直在尝试从 SIM 卡读取/写入,但仍然没有成功。
到目前为止,这是我的代码:
//read from sim
public String adding() {
Uri simUri = Uri.parse("content://icc/adn/");
Cursor cursorSim = this.getContentResolver().query(simUri, null, null,null, null);
String b = "";
while (cursorSim.moveToNext()) {
b+= (cursorSim.getString(cursorSim.getColumnIndex("name")));
b += "\n" + (cursorSim.getString(cursorSim.getColumnIndex("_id")));
b+= "\n" + (cursorSim.getString(cursorSim.getColumnIndex("number")));
}
return b;
}
//to write to sim
public void testing4() {
ContentValues values = new ContentValues();
values.put( "tag", "test" );
values.put( "number", "1234" );
getContentResolver().insert( Uri.parse("content://icc/adn/"); , values
);
}
如果您对此有所了解,请告诉我。
谢谢
I've been trying to read/write from sim card but still there's no luck.
here's my code so far:
//read from sim
public String adding() {
Uri simUri = Uri.parse("content://icc/adn/");
Cursor cursorSim = this.getContentResolver().query(simUri, null, null,null, null);
String b = "";
while (cursorSim.moveToNext()) {
b+= (cursorSim.getString(cursorSim.getColumnIndex("name")));
b += "\n" + (cursorSim.getString(cursorSim.getColumnIndex("_id")));
b+= "\n" + (cursorSim.getString(cursorSim.getColumnIndex("number")));
}
return b;
}
//to write to sim
public void testing4() {
ContentValues values = new ContentValues();
values.put( "tag", "test" );
values.put( "number", "1234" );
getContentResolver().insert( Uri.parse("content://icc/adn/"); , values
);
}
please let me know if you know something about this.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
写给 usim 的信中有一些拼写错误。
此外,还应在 AndroidManifest.xml 中添加该权限。
(附带问题)
在simsalabim的源代码中,我不知道类变量“Contact”的含义。
我找不到可以导入的包。在日食中,“联系”行中有错误。
源代码说文件
content://icc/adn
适用于 1.6 以上的 android 版本,1.5content://sim/adn
则适用。(侧面结果)
我发现“数字”字段的大小可以超过 64 个字符。在读取过程中,可以检索到正确的值。
但真实的手机屏幕无法显示完整的字符。
There is some misspelling in the writing to usim.
Also the permission should be added in the AndroidManifest.
(Side question)
In the simsalabim's source code, I don't know the meaning of the class variable "Contact".
I can't find the package which can be imported. In the eclipse, there are errors in the "Contact" lines.
The source code says that the file
content://icc/adn
is for the android version over 1.6, for 1.5content://sim/adn
.(Side result)
I found the size of "number" field can be over 64 characters. In the read process, the correct value can be retrieved.
But the real phone screen can't show the full characters.
您是否已将权限添加到
AndroidManifest
中?您应该具备:
您还可以从 simsalabim 的源代码中获得一些想法。
Have you added the permissions to the
AndroidManifest
?You should have:
You can also get some ideas from simsalabim's source code.