从其他类调用一个类的函数

时间:2013-11-06 20:37:48

标签: java android class

我有一个名为SResponses的类,它具有“getsrthreadid”功能,我试图从我的其他类调用它,我这样做:

SResponses sres=new SResponses();
String queryz = "SELECT " + MySQLiteHelper.COLUMN_ID + "," + MySQLiteHelper.COLUMN_MESSAGE+","+MySQLiteHelper.COLUMN_THREADID+","+MySQLiteHelper.COLUMN_POSITION + " FROM " + MySQLiteHelper.TABLE_NAME + " WHERE "+MySQLiteHelper.COLUMN_THREADID+ "="+sres.getsrthreadid();

//Log.e("datasource", sres.getsrthreadid());
cursors = database.rawQuery(queryz, null);

SResponses类中的函数定义为:

private String threadid;

public String  getsrthreadid()
{
    return threadid;
}

@Override
public void onCreate(Bundle savedInstanceState) 
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.sresponses);
    datasource = new DataSource(getApplicationContext());
    datasource.open();

    Intent intent=getIntent();

    threadid = intent.getStringExtra("threadid"); 
}

但我从这个功能中得不到任何价值。请帮我找出问题。

Logcat错误

 11-07 01:43:01.072: E/AndroidRuntime(848): java.lang.RuntimeException: Unable to start activity ComponentInfo{soft.b.peopleassist/soft.b.peopleassist.SResponses}: java.lang.NullPointerException: println needs a message

0 个答案:

没有答案