English 中文(简体)
申请停止了意外的工作。 请再次审判
原标题:Application stopped working unexpectedly. Please try again
  • 时间:2010-11-28 13:39:46
  •  标签:
  • java
  • android

我正试图展示来自海底电话簿的联络人的姓名和号码,即我的DVD储存的联络人。 任何人都能够告诉我这一法典有什么错误。 请再次审判......

public class get extends Activity {
        private void getColumnData(Cursor cur)
    {
        if(cur.moveToFirst())
        {
            int numi=cur.getColumnIndex(People.NUMBER);
            int namei=cur.getColumnIndex(People.NAME);
            String name,num;
            do{
                name=cur.getString(namei);
                num=cur.getString(numi);

            }while(cur.moveToNext());
        }
    }
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Uri u=People.CONTENT_URI;
        String[] proj=new String[]{People.NAME,People.NUMBER};
        Cursor cur=managedQuery(u, proj, null, null, null);
        getColumnData(cur);
        TextView tv=new TextView(this);
        tv.setText("First step");
        setContentView(tv);
    }
}
问题回答

Try using android.provider.ContactsContract. 联系人;

还在Manifest案卷中准许CONTACTS

import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts;

清单 lv= (ListView)findViewById(R.id.list_view);

Uri uri=Contacts.CONTENT_URI;

String [] projection=new String[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME};
Cursor c=managedQuery(uri,null, null, null, null);
String[] from=new String[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME};
int[] to=new int[]{android.R.id.text1,android.R.id.text2};
SimpleCursorAdapter sAdapter=new SimpleCursorAdapter(this,android.R.layout.simple_list_item_2, c, from, to);
lv.setAdapter(sAdapter);

Also put in the manifest file





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签