Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. public class deletedaily extends AsyncTask<Void , Void, long[]>{
  2.  
  3. ProgressDialog pd;
  4. long resultdelete;
  5. protected void onPreExecute(){
  6.  
  7. pd=new ProgressDialog(StockDetail.this);
  8. if(pd!=null){
  9. pd.setMessage("Deleting data.....please wait");
  10. pd.show();
  11. }
  12.  
  13.  
  14. }
  15.  
  16. protected long[] doInBackground(Void... params) {
  17. // TODO Auto-generated method stub
  18.  
  19. try{
  20.  
  21. Database.getInstance(getApplicationContext()).getWritableDatabase().beginTransaction();
  22. resultdelete= Database.getInstance(getApplicationContext()).getWritableDatabase().delete(st.tablename, st.column2 + "=? AND " + st.column3 + "=?", new String[] {getdailydate.toString(),stockname} );
  23. Database.getInstance(getApplicationContext()).getWritableDatabase().setTransactionSuccessful();
  24.  
  25. new popdailydata().execute(); //here calling list view to populate after deletion
  26. }
  27. catch(Exception dailydeleteerror){}
  28. finally{
  29. Database.getInstance(getApplicationContext()).getWritableDatabase().endTransaction();
  30. }
  31. return new long[] {resultdelete};
  32. }
  33.  
  34.  
  35. protected void onPostExecute(long result){
  36.  
  37. System.out.println("postexecute entered");
  38. if(pd!=null){
  39. pd.dismiss();
  40. }
  41.  
  42. if(result!=-1){
  43. Toast.makeText(getApplicationContext(),"Date deleted from your portfolio", Toast.LENGTH_LONG).show();
  44. }
  45. else{
  46. Toast.makeText(getApplicationContext(),"Failed to delete ....try again", Toast.LENGTH_LONG).show();
  47. }
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement