Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class deletedaily extends AsyncTask<Void , Void, long[]>{
- ProgressDialog pd;
- long resultdelete;
- protected void onPreExecute(){
- pd=new ProgressDialog(StockDetail.this);
- if(pd!=null){
- pd.setMessage("Deleting data.....please wait");
- pd.show();
- }
- }
- protected long[] doInBackground(Void... params) {
- // TODO Auto-generated method stub
- try{
- Database.getInstance(getApplicationContext()).getWritableDatabase().beginTransaction();
- resultdelete= Database.getInstance(getApplicationContext()).getWritableDatabase().delete(st.tablename, st.column2 + "=? AND " + st.column3 + "=?", new String[] {getdailydate.toString(),stockname} );
- Database.getInstance(getApplicationContext()).getWritableDatabase().setTransactionSuccessful();
- new popdailydata().execute(); //here calling list view to populate after deletion
- }
- catch(Exception dailydeleteerror){}
- finally{
- Database.getInstance(getApplicationContext()).getWritableDatabase().endTransaction();
- }
- return new long[] {resultdelete};
- }
- protected void onPostExecute(long result){
- System.out.println("postexecute entered");
- if(pd!=null){
- pd.dismiss();
- }
- if(result!=-1){
- Toast.makeText(getApplicationContext(),"Date deleted from your portfolio", Toast.LENGTH_LONG).show();
- }
- else{
- Toast.makeText(getApplicationContext(),"Failed to delete ....try again", Toast.LENGTH_LONG).show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement