显示从静态方法Android调用空指针异常

时间:2015-02-21 07:01:55

标签: java android android-sqlite static-methods

有三个类History,Databasehandlreone,DatabaseHandler。在历史记录调用中,有一个名为addHistory(记录记录)的静态方法。它调用非静态方法,该方法在同一个名为calling(String u)的类中。

历史

    class History extends Activity{
    public static long addHistory(Record record) {
    String u=record.getURL();
    History ss=new History();
    ss.calling(u);
    }
    private void calling(String u) {
            DatabaseHandlerone db=new DatabaseHandlerone(History.this);
            try{
            db.good(u); 
            }catch(Exception e){
                Log.v("Error",e.toString());
            }}}

在调用函数时,它调用名为good的函数,该函数位于另一个类名Databasehandlerone中。

DatabaseHandlerone.java

    public class DatabaseHandlerone {
        public DatabaseHandlerone(History history) {
            // TODO Auto-generated constructor stub
        }

    public void good(String s){
            try{
            DatabaseHandler db=new DatabaseHandler(DatabaseHandlerone.this);
            db.deleteall(s); 
            }catch(Exception e){
                Log.v("Calling from DatabseHandler1",e.toString());
            }   }

在良好的函数中,将调用deleteall函数,这是另一个名为DatabaseHandler的类。

当我调用db.deleteall(s)时。它显示了Java.NullPointerException错误。任何人都可以帮助。

DatabseHandler.this

    public class DatabaseHandler extends SQLiteOpenHelper {
         public void deleteall(String s){
          Log.v("value",s);
         }

logcat的

            02-21 11:46:35.941: D/libc-netbsd(22197): getaddrinfo: stackoverflow.com get result from proxy >>
            02-21 11:46:35.943: D/ID Safe Utils(22197): leave sendOpenUrlBroadcast
            02-21 11:46:35.959: V/Good(22197): http://stackoverflow.com/users
            02-21 11:46:35.959: V/Calling(22197): http://stackoverflow.com/users
            02-21 11:46:35.959: V/After Databse(22197): After DatabseHandler Calling
            02-21 11:46:35.959: V/Value(22197): http://stackoverflow.com/users
            02-21 11:46:35.959: V/String(22197): http://stackoverflow.com/users
            02-21 11:46:35.960: V/DatabaseHandler()(22197): Afert SdCard
            02-21 11:46:35.960: V/Calling from DatabseHandler1(22197): java.lang.NullPointerException
            02-21 11:46:35.960: V/DatabaseHandler()(22197): Afert SdCard
            02-21 11:46:35.960: V/Retreiving Values:(22197): java.lang.NullPointerException

0 个答案:

没有答案