java.lang.IllegalArgumentException:列'data3'不存在 什么是data3 column ??
logcat的
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):致命 例外:主要
03-24 07:05:36.091: ERROR / AndroidRuntime(2540): java.lang.RuntimeException:无法 开始活动 ComponentInfo {fypj.e / fypj.e.e}: java.lang.IllegalArgumentException异常: 列'data3'不存在
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread.access $ 2300(ActivityThread.java:125)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2033)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.os.Looper.loop(Looper.java:123)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread.main(ActivityThread.java:4627)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at java.lang.reflect.Method.invokeNative(母语 方法)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at java.lang.reflect.Method.invoke(Method.java:521)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at dalvik.system.NativeStart.main(母语 方法)
03-24 07:05:36.091: ERROR / AndroidRuntime(2540):引起: java.lang.IllegalArgumentException异常: 列'data3'不存在
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:99)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.widget.SimpleCursorAdapter。(SimpleCursorAdapter.java:87)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at fypj.e.e.onCreate(e.java:48)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-24 07:05:36.091: 错误/ AndroidRuntime(2540):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-24 07:05:36.091: ERROR / AndroidRuntime(2540):... 11 更
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);
}
}
答案 0 :(得分:0)
只有猜测可能,但也许你正在使用" data3"作为数据库工作的一些函数的参数,以及" data3"在您的数据库中不存在?
答案 1 :(得分:0)
我不知道你使用的是哪个sdk但是2.2中的大多数数据包都被删除了。但是问题是具有常量值“data3”的列Phone.Label在光标返回的列中不存在。