游标初始化错误:内容提供程序中的列值始终为-1

时间:2017-07-05 19:05:37

标签: android

这是我得到的错误     致命的例外:主要

for app in NSWorkspace.shared().runningApplications {
    let pid = app.processIdentifier

    var tai = proc_taskallinfo()
    let size = MemoryLayout<proc_taskallinfo>.size
    var result = proc_pidinfo(pid, PROC_PIDTASKALLINFO, 0, &tai, Int32(size))
    let fileCount: Int32 = Int32(tai.pbsd.pbi_nfiles)

    if result <= 0 {
        continue
    }

    var fid = Array(repeating: proc_fdinfo(), count: Int(fileCount))
    let fdInfoSize = MemoryLayout<proc_fdinfo>.stride
    result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, &fid, Int32(fdInfoSize) * fileCount)

    if result <= 0 {
        Swift.print("Error PROC_PIDLISTFDS.")
    }
    else {
        for i in 0.. < Int(result) / fdInfoSize {
            let fdp = fid[i]

            if fdp.proc_fdtype == UInt32(PROX_FDTYPE_SOCKET) {
                var si = socket_fdinfo()
                let sizeSi = MemoryLayout<socket_fdinfo>.size
                result = proc_pidfdinfo(pid, fdp.proc_fd, PROC_PIDFDSOCKETINFO, &si, Int32(sizeSi))

                if result <= 0 {
                    Swift.print("Error PROC_PIDFDSOCKETINFO: " + errno.description)
                }
                else {
                    if si.psi.soi_kind == Int32(SOCKINFO_TCP) {
                        Swift.print("TCP Socket")
                    }
                }
            }
        }
    }
}

这是属性集       / **************数据库表       COLUMNS ***************************************** /

Process: com.example.yaamu.survey_contentprovider, PID: 17250

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yaamu.survey_contentprovider/com.example.yaamu.survey_contentprovider.Database_Activitry}: java.lang.IllegalStateException: Couldn't read row 3, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
                                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                          at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                          at android.os.Looper.loop(Looper.java:154)
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                                       Caused by: java.lang.IllegalStateException: Couldn't read row 3, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
                                                                                          at android.database.CursorWindow.nativeGetString(Native Method)
                                                                                          at android.database.CursorWindow.getString(CursorWindow.java:438)
                                                                                          at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
                                                                                          at android.database.CursorWrapper.getString(CursorWrapper.java:137)
                                                                                          at com.example.yaamu.survey_contentprovider.Database_Activitry.onCreate(Database_Activitry.java:33)
                                                                                          at android.app.Activity.performCreate(Activity.java:6679)
                                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                                                                                          at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                          at android.os.Looper.loop(Looper.java:154) 
                                                                                          at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

表格已创建。

 public static final String TABLE_DATABASE = "database_table";
public static final String COLUMN_DB_QUEST_ID = "question_question_id";
public static final String COLUMN_DB_SURVEYID = " survey_id";
public static final String COLUMN_QUESTION = " question_ques";
public static final String COLUMN_TYPE_OF_ANSWER = "type_of_answer";
public static final String COLUMN_IS_VALIDATION = "is_validation";
public static final String COLUMN_ANSWER_TYPE_FILTER = "answer_type_filter";
public static final String COLUMN_IS_REQUIRED = "is_required";
public static final String COLUMN_IS_SHUFFLE = "is_shuffle";
public static final String COLUMN_LINEAR_MIN_VALUE = "linear_min_value";
public static final String COLUMN_LINEAR_MAX_VALUE = "linear_max_value";
public static final String COLUMN_LINEAR_MIN_LABEL = "linear_min_label";
public static final String COLUMN_LINEAR_MAX_LABEL = "linear_max_label";
public static final String COLUMN_RATING_VALUE = "rating_value";
/**********************************************************************************************/

已添加值。它显示在toast消息中,但我无法检索值

我使用了另一个活动来检索值

  private static final String DATABASE_TABLE_CREATE = " create table "
        + TABLE_DATABASE + "("
        + COLUMN_DB_QUEST_ID + " integer primary key autoincrement, "
        + COLUMN_DB_SURVEYID + " integer not null, "
        + COLUMN_QUESTION + " text not null, "
        + COLUMN_TYPE_OF_ANSWER + " text not null, "
        + COLUMN_IS_VALIDATION + " boolean, "
        + COLUMN_ANSWER_TYPE_FILTER + " text, "
        + COLUMN_IS_REQUIRED + " boolean not null,"
        + COLUMN_IS_SHUFFLE + " boolean, "
        + COLUMN_LINEAR_MIN_VALUE + " integer, "
        + COLUMN_LINEAR_MAX_VALUE + " integer, "
        + COLUMN_LINEAR_MIN_LABEL + " text,"
        + COLUMN_LINEAR_MAX_LABEL + " text, "
        + COLUMN_RATING_VALUE + " integer );";

谢谢你

1 个答案:

答案 0 :(得分:0)

这只是因为在定义列属性COLUMN_DB_SURVEYID和COLUMN_QUESTION时初始化了一个空格。 谢谢你的回复!