2013-08-04 38 views
0

我想在我的android數據庫中存儲值。我能夠存儲值,但我的問題是,當我正在檢查將值存儲在數據庫中時,我的應用程序正在崩潰,在特定的實例中我可以找到錯誤。Android獲取失敗,同時檢查phpresponse

請任何人幫助我解決這個問題。這是我的短代碼。

ResponseHandler<String> responseHandler = new BasicResponseHandler(); 
     final String response = httpclient.execute(httppost, responseHandler); 
     System.out.println("Response : " + response); 


     if(response.equalsIgnoreCase("Entered data successfully")){ 
      runOnUiThread(new Runnable() { 
       public void run() { 
        Toast.makeText(lifequality.this,"Inserted Successully", Toast.LENGTH_SHORT).show(); 
       } 
      }); 

      myIntent=new Intent(lifequality.this, menu.class); 

      String uname; 
      uname=myValues.getString("value").toString(); 

      myIntent.putExtra("value", uname); 
      startActivity(myIntent); 
     }else{ 
      showAlert(); 
      startActivity(new Intent(lifequality.this, lifequality.class)); 
     } 

    }catch(Exception e){ 
     dialog.dismiss(); 
     System.out.println("Exception : " + e.getMessage()); 
    } 


} 


    public void showAlert(){ 
     lifequality.this.runOnUiThread(new Runnable() { 
      public void run() { 
       AlertDialog.Builder builder = new AlertDialog.Builder(lifequality.this); 
       builder.setTitle("error in inserting."); 
       builder.setMessage("not inserted.") 
         .setCancelable(false) 
         .setPositiveButton("OK", new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int id) { 
          } 
         });      
       AlertDialog alert = builder.create(); 
       alert.show();    
      } 
     }); 
} 

回答

0

我已經解決了我的問題。爲了幫助我在這裏發佈我的答案。 請通過調試模式檢查您的響應,因爲我得到的響應是「成功插入/ r/n/n/n」。我在調試模式下找到了它。你也是如此,問題可以解決。