How to send data from Fragment to an Activity in Android?

Programing android i am trying to delete data from database at the onCreate activity stage?

  • import java.io.File; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class DicemanActivity extends Activity { /** Called when the activity is first created. */ private static final String DB_PATH = "Data/data/<diceman>databases<GameData>"… @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); doDBCheck(); Button button1 = (Button)findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v){ Intent intent = new Intent(v.getContext(),play.class); startActivityForResult(intent, 0); } }); } private void doDBCheck(){ try{ File file = new File(DB_PATH); }catch (Exception ex){ } } }

  • Answer:

    Have you modified the manifest file to give the app read/write permissions? If not, add <uses-permission android:name="android.permission. WRITE_EXTERNAL_STORAGE" /> to AndroidManifest.xml (without the new line, for some reason it wasn't displaying properly...)

Thomas at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.