开发者

android debug error column 'data3' does not exist

java.lang.IllegalArgumentException: column 'data3' does not exist whats with data3 column??

LogCat

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): FATAL EXCEPTION: main

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): java.lang.RuntimeException: Unable to start activity ComponentInfo{fypj.e/fypj.e.e}: java.lang.IllegalArgumentException: column 'data3' does not exist

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread.access$2300(ActivityThread.java:125)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

03-24 07开发者_StackOverflow中文版:05:36.091: ERROR/AndroidRuntime(2540): at android.os.Handler.dispatchMessage(Handler.java:99)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.os.Looper.loop(Looper.java:123)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread.main(ActivityThread.java:4627)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at java.lang.reflect.Method.invokeNative(Native Method)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at java.lang.reflect.Method.invoke(Method.java:521)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at dalvik.system.NativeStart.main(Native Method)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): Caused by: java.lang.IllegalArgumentException: column 'data3' does not exist

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:99)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.widget.SimpleCursorAdapter.(SimpleCursorAdapter.java:87)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at fypj.e.e.onCreate(e.java:48)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

03-24 07:05:36.091: ERROR/AndroidRuntime(2540): ... 11 more

package fypj.e;

import android.app.ListActivity; 
import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor; 
import android.net.Uri;
import android.os.Bundle; 
import android.provider.Contacts.People; 
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone; 
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
import android.widget.*;  

public class e extends ListActivity  {
    private SimpleCursorAdapter myAdapter;     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ContentValues values = new ContentValues(); 
        values.put(RawContacts.ACCOUNT_TYPE, ""); 
        values.put(RawContacts.ACCOUNT_NAME, ""); 
        Uri rawContactUri = 
getContentResolver().insert(RawContacts.CONTENT_URI, values); 
        long rawContactId = ContentUris.parseId(rawContactUri); 


        values.clear(); 
        values.put(Data.RAW_CONTACT_ID, rawContactId); 
        values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); 
        values.put(StructuredName.DISPLAY_NAME, "Misha"); 
        values.put(Phone.LABEL, "Mis");
        values.put(ContactsContract.Data.DATA3, "View Contact");
        getContentResolver().insert(Data.CONTENT_URI, values); 


        //contentResolver = getContentResolver(); 



        Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null);         
        startManagingCursor(cursor);          
        String[] column = new String[] {Phone.LABEL};         
        int[] names = new int[] {R.id.contact_name};         
        myAdapter = new SimpleCursorAdapter(this, R.layout.main, cursor, column, names);         
        setListAdapter(myAdapter);     
    } 
}


I don't know which sdk are you using but in 2.2 most of the packets are depricated. However the problem is that the column Phone.Label which has constant value "data3" is not present in the columns return by the cursor.


Nothing but guesses possible but maybe you are using "data3" as an argument to some function that does database work, and "data3" does not exist in your database?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜