简体   繁体   中英

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.ee}: 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: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.eeonCreate(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);     
    } 
}

除了猜测之外,别无所求,但是也许您正在使用“ data3”作为数据库工作某个函数的参数,而“ data3”在您的数据库中不存在?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM