I've read android.app.Application cannot be cast to android.app.Activity but I didn't solve my problem. I tried to write in code
totalebevuto = (TextView) this.findViewById(R.id.totalebevuto);
as suggested in the post but I get an error.
public class MyReceiver2 extends BroadcastReceiver {
WordListOpenHelper mDB;
WordListAdapter mAdapter;
TextView totalebevuto;
@Override
public void onReceive(Context context, Intent intent) {
mDB = new WordListOpenHelper(context);
// AGGIUNGERE LA DATA AL DATABASE
totalebevuto = (TextView) ((Activity)context).findViewById(R.id.totalebevuto);
mDB.insert_daily(Integer.parseInt(totalebevuto.getText().toString()));
mDB.clear();
mAdapter = new WordListAdapter(context, mDB);
mAdapter.notifyDataSetChanged();
Toast.makeText(context, "OnReceive2", Toast.LENGTH_LONG).show();
}
}