How to get the context in the marked position? - android

I am trying to use parse.com in an android application of mine, how to get the context at the place of *** in the code AlertDialog.Builder(*******)? I tried using getApplicationcontext which doesn't work.Can anyone with experience in the android help me with respect to this?
mSignInButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
mVibrator.vibrate(100);
//Checking for internet connection...
ConnectivityManager cm =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
//internet connection inactive... show alert...
if (!(netInfo != null && netInfo.isConnectedOrConnecting())) {
AlertDialog.Builder adb = new AlertDialog.Builder(arg0.getContext());
adb.setTitle("ALERT");
adb.setMessage("Please turn on Internet.");
adb.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Ok' Button
}
});
adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Cancel' Button
dialog.cancel();
}
});
adb.setIcon(R.drawable.ic_launcher);
adb.show();
}else{
ParseQuery<ParseObject> query = ParseQuery.getQuery("Admin");
query.whereEqualTo("password", mUserNameEditText.getText().toString());
query.whereEqualTo("userName", mPasswordEditText.getText().toString());
query.countInBackground(new CountCallback() {
public void done(int count, ParseException e) {
if (e == null) {
// The count request succeeded. Log the count
Log.d("test", "Sean has played " + count + " games");
if(count>0){
// save the login status... loggedIn/notloggedIn...
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(LoginScreenActivity.this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("isLoggedIn", true);
editor.commit();
// if user name password is correct, navigate to next activity...
Intent intent = new Intent(LoginScreenActivity.this,OptionScreenActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent, 0);
overridePendingTransition(R.layout.fade_in, R.layout.fade_out);
}else{
AlertDialog.Builder adb = new AlertDialog.Builder(*********************);
adb.setTitle("ALERT");
adb.setMessage("Wrong username or password.");
adb.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Ok' Button
}
});
adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Cancel' Button
dialog.cancel();
}
});
adb.setIcon(R.drawable.ic_launcher);
adb.show();
}
} else {
// The request failed
}
}
});

Try out as below:
AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext());
OR
AlertDialog.Builder adb = new AlertDialog.Builder(<YourActivity>.this);

Related

How to detect if user disable granted permissions in the settings in android?

In android 6.0 and above the permissions granted at run time and the user can cancel the granted permissions by going to the settings.
I want to run some code just after the user cancels the granted permissions by going to the settings. Is there anyway to do it?
// call this for checking the permission before other Activity or function //to call
if (hasPermission()) {
// do thing
} else {
requestPermissionDialog();
}
/////////////////hasPermission////////////////////////////
private boolean hasPermission() {
boolean permission = true;
if (ActivityCompat.checkSelfPermission(WelcomeActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
permission = false;
}
return permission;
}
//////////////////////////requestPermissionDialog///////////////////////
private void requestPermissionDialog() {
permissionStatus = getSharedPreferences("permissionStatus", MODE_PRIVATE);
if (ActivityCompat.checkSelfPermission(WelcomeActivity.this, Manifest.permission.WRITE_Eenter code hereXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(WelcomeActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
//Show Information about why you need the permission
// resetPasswordDialog(WelcomeActivity.this,"ok");
AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
builder.setInverseBackgroundForced(true);
builder.setTitle("Storage Permission");
builder.setMessage("This app needs Storage permission.");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
ActivityCompat.requestPermissions(WelcomeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_CONSTANT);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
} else if (permissionStatus.getBoolean(Manifest.permission.WRITE_EXTERNAL_STORAGE, false)) {
//Previously Permission Request was cancelled with 'Dont Ask Again',
// Redirect to Settings after showing Information about why you need the permission
// resetPasswordDialog(WelcomeActivity.this,"settings");
AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
builder.setInverseBackgroundForced(true);
builder.setTitle(" Storage Permission");
builder.setMessage("This app needs Storage permission.");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
sentToSettings = true;
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
Toast.makeText(getBaseContext(), "Go to Permissions to allow Storage Audio ", Toast.LENGTH_LONG).show();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
} else {
//just request the permission
ActivityCompat.requestPermissions(WelcomeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_CONSTANT);
}
SharedPreferences.Editor editor = permissionStatus.edit();
editor.putBoolean(Manifest.permission.WRITE_EXTERNAL_STORAGE, true);
editor.commit();
}
}

Android request location permission causes alertdialog to display twice

I am trying to display user current location when clicking a button using this code:
mButton = (Button) findViewById(R.id.mButton);
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
String[] permissions;
permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(MainActivity.this, permissions, 4);
else {
mButton.setText("");
// request and display location
}
}
});
So far, so good, but when I am checking the permissions results (onRequestPermissionsResult) I am using a for statement to iterate the permissions array and inside I am creating a dialog to explain why the current permission is needed. The problem is - because the permissions needed are ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION the for statement runs twice, here is my code:
#Override
public void onRequestPermissionsResult(int requestCode, #NonNull String[] permissions, #NonNull int[] grantResults) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
if (requestCode == 4) {
for (int i = 0, len = permissions.length; i < len; i++) {
String permission = permissions[i];
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
boolean showRationale = shouldShowRequestPermissionRationale(permission);
if (!showRationale) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The application must have permission to find location");
builder.setTitle("Location");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", MainActivity.this.getPackageName(), null);
intent.setData(uri);
MainActivity.this.startActivity(intent);
}
});
builder.setNegativeButton("Later", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.show();
} else if (Manifest.permission.ACCESS_COARSE_LOCATION.equals(permission) || Manifest.permission.ACCESS_FINE_LOCATION.equals(permission)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The application must have permission to find location");
builder.setTitle("Location");
builder.setNegativeButton("Later", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
String[] permissionss = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
ActivityCompat.requestPermissions(MainActivity.this, permissionss, 4);
}
});
builder.show();
}
Toast.makeText(MainActivity.this, "No permission to use location", Toast.LENGTH_LONG).show();
} else if (grantResults.length > 0 && grantResults[i] == PackageManager.PERMISSION_GRANTED)
// request and display location
}
}
}
}
There are many solutions I thought of, passing only one permission in the permissions String[] array, showing the dialog with an if statement only if(i==0). I don't know what is the correct solution for this problem. Thanks.
P.S - Sorry for my English.
NEW FINAL WORKING CODE WITH LIBRARY:
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)
requestLocation();
else
MainActivityPermissionsDispatcher.requestLocationWithCheck(MainActivity.this);
}
});
#NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
public void requestLocation() {
double lo = 0.0, la = 0.0;
removeItem();
myToast = Toast.makeText(MainActivity.this, lo + " , " + la, Toast.LENGTH_LONG);
myToast.show();
// Get Location And Display It Using Toast.
showQuestion("Location");
}
#OnNeverAskAgain({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
void showNeverAskForLocation() {
Toast.makeText(this, R.string.permission_location_neverask, Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The application must have permission to find location");
builder.setTitle("Location");
builder.setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", MainActivity.this.getPackageName(), null);
intent.setData(uri);
MainActivity.this.startActivity(intent);
}
});
builder.setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.show();
}
#OnShowRationale({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
void showRationaleForLocation(final PermissionRequest request) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("The application must have permission to find location");
builder.setTitle("Location");
builder.setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
#Override
public void onClick(#NonNull DialogInterface dialog, int which) {
request.proceed();
}
});
builder.setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
#Override
public void onClick(#NonNull DialogInterface dialog, int which) {
request.cancel();
}
});
builder.show();
}
#OnPermissionDenied({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
void showDeniedForLocation() {
Toast.makeText(this, R.string.permission_location_denied, Toast.LENGTH_SHORT).show();
}

How to show alert message in an android app

I am trying to show an alert message.
But when I click the specific button to show the alert message the app stops unfortunately.
my code for alert message is here...
search.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Cursor res = myDB.getAllData();
if (res.getCount() == 0) {
showMessage("Error", "Nothing found");
return;
}
StringBuffer buffer = new StringBuffer();
while (res.moveToNext()) {
buffer.append("EMAIL: " + res.getString(0) + "\n");
buffer.append("full_name : " + res.getString(1) + "\n");
buffer.append("district : " + res.getString(2) + "\n");
buffer.append("phone_num : " + res.getString(3) + "\n");
}
showMessage("Data", buffer.toString());
}
});
}
public void showMessage(String title, String message)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
Try this code :
AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage("Write your message here.");
builder1.setCancelable(true);
builder1.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
builder1.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
instead of
AlertDialog.Builder builder = new AlertDialog.Builder(this);
use this
AlertDialog.Builder builder = new AlertDialog.Builder(YourActivity.this); // for activity
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // for fragment
I have tested showMessage method. and it worked without no problem. I guess you must check your database connection ,cursor and buffer. However This code is for showing an alert message:
/**
* #param context
* #param title
* #param message
*
* Caution:Error--> android.view.WindowManager$BadTokenException:
* Unable to add window -- token null is not for an application
*
* --> Instead of getApplicationContext(), just use
* ActivityName.this
*/
public static AlertDialog showDialog(final Context context, String title,
String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true);
builder.setMessage(message);
builder.setTitle(title);
builder.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
return builder.show();
}
public static void showAlert(final Activity activity, String title,
String message, final boolean finish) {
new AlertDialog.Builder(activity).setTitle(title).setMessage(message)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.dismiss();
if (finish) {
activity.finish();
}
}
}).show();
}

Properly setting up an alertdialog on Activity closing?

I have an activity with two score numbers. I want the user to choose a winner if they're the same when it closes (i.e. player 1 or player2). As a .NET person, I'm trying to basically do the MessageBox.
Unfortunately, from what I've read, android doesn't do UI threads the same way. And that the activity has "a leaked window". I looked on SO and I saw the idea was to put "dismiss" in "onPause". However, I didn't see a "onPause" function and was confused to how to implement it. So I tried what I have below, but got the same error.
What can I do to this guy in order to make sure this works properly?
public void onFinish(View v) {
//get scores
TextView score1tv = (TextView) findViewById(R.id.tvScore1);
score1 = score1tv.getText().toString();
TextView score2tv = (TextView) findViewById(R.id.tvScore2);
score2 = score2tv.getText().toString();
//Make sure they aren't the same
int i_Score1 = Integer.parseInt(score1);
int i_Score2 = Integer.parseInt(score2);
if (i_Score1 == i_Score2){
//alert user
new AlertDialog.Builder(this)
.setTitle("Duplicate score")
.setMessage("Whose score won the bout?")
.setPositiveButton(boutData[1], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//fencer 1 won
score1 = "V" + score1;
dialog.dismiss();
}
})
.setNegativeButton(boutData[3], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
score2 = "V" + score2;
dialog.dismiss();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.create()
.show();
}
Intent intent = new Intent();
intent.putExtra("edittextvalue","value_here");
setResult(RESULT_OK, intent);
finish();
}
Edit: Here's the solution I came to thanks to the help I received:
public void onFinish(View v) {
//get scores
TextView score1tv = (TextView) findViewById(R.id.tvScore1);
score1 = score1tv.getText().toString();
TextView score2tv = (TextView) findViewById(R.id.tvScore2);
score2 = score2tv.getText().toString();
//Make sure they aren't the same
int i_Score1 = Integer.parseInt(score1);
int i_Score2 = Integer.parseInt(score2);
if (score1 == score2){
//alert user
new AlertDialog.Builder(this)
.setTitle("Duplicate score")
.setMessage("Whose score won the bout?")
.setPositiveButton(boutData[1], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//fencer 1 won
score1 = "V" + score1;
//close out
Intent intent = new Intent();
intent.putExtra("edittextvalue","value_here");
setResult(RESULT_OK, intent);
finish();
}
})
.setNegativeButton(boutData[3], new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
score2 = "V" + score2;
//close out
Intent intent = new Intent();
intent.putExtra("edittextvalue","value_here");
setResult(RESULT_OK, intent);
finish();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.create()
.show();
}
else{
Intent intent = new Intent();
intent.putExtra("edittextvalue","value_here");
setResult(RESULT_OK, intent);
finish();
}
}
Put the last four lines into an else clause and do something similar in your onClick methods.
Also you shouldn't have to call dialog.dismiss() manually.

How to "Save as" via Button programmatically

In my android app, I'm producing a lot of data which I store at the moment in a .txt file simply called "logData". Now my boss wants me to give him the possibility to save it as an extra file, like the Save As Button in various windows programms.
At the moment I have a method for generating a logFile and write first data to it and one for writing all coming data to it. But how can I implement a "Save as" functionality?
Here the code of both methods and the used variables:
private String logData = "logData.txt";
private String logText = "";
private File extStorageDir = Environment.getExternalStorageDirectory();
private File mLogFile = new File(extStorageDir, "DCULogData/logData.txt");
generating:
public void generateLogFileOnSD(String sFilename, String sBody) {
try {
File logFile = new File(extStorageDir, sFilename);
FileWriter writer = new FileWriter(logFile);
writer.append(sBody);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
writing:
public void writeLogFileOnSD(String sFilename, String sBody) {
if (mLogFile.exists()) {
try {
FileOutputStream fOut = new FileOutputStream(mLogFile);
OutputStreamWriter mOutWriter = new OutputStreamWriter(fOut);
mOutWriter.append(sBody);
mOutWriter.close();
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
} else {
generateLogFileOnSD(logData, logText);
}
}
EDIT : This is my solution based on Simple Plan's answer. Thanks for this!
I also tested some scenarios with filenames like "/blabla", "m/m/m/m/m/". No failure found until now :)
public Button.OnClickListener saveLogFileOnClickListener = new Button.OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(
DiagnosisActivity.this);
builder.setTitle(R.string.save_file_dialog);
builder.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final EditText input = new EditText(
DiagnosisActivity.this);
input.setSingleLine();
AlertDialog.Builder ad = new Builder(
DiagnosisActivity.this);
ad.setTitle("Enter save as File Name");
ad.setView(input);
ad.setCancelable(true);
ad.setPositiveButton("Save as",
new DialogInterface.OnClickListener() {
#Override
public void onClick(
DialogInterface dialog,
int which) {
int len = input.length();
if (len != 0) {
final_filename = input
.getText().toString()
.trim();
generateLogFileOnSD(
"DCULogData/"
+ final_filename
+ ".txt",
ReceiverThread
.getLogText());
Toast.makeText(
getApplicationContext(),
"Saved!",
Toast.LENGTH_LONG)
.show();
} else {
Toast.makeText(
getApplicationContext(),
"Enter a proper name",
Toast.LENGTH_LONG)
.show();
}
}
});
ad.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.cancel();
}
});
AlertDialog alert = ad.create();
alert.show();
}
});
builder.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert1 = builder.create();
alert1.show();
}
};
First add Button into your Layout as a text Save as and implement OnClickListner()
String final_filename;
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
annual_crop.setTextColor(Color.BLUE);
AlertDialog.Builder al1 = new Builder(youractivity);
al1.setMessage("Do you want to save a file?");
al1.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
final EditText input = new EditText(
youractivity.this);
input.setSingleLine();
AlertDialog.Builder al = new Builder(
AgriListView.this);
al.setTitle("Enter save as File Name");
al.setView(input);
al.setCancelable(true);
al.setIcon(R.drawable.bt);
al.setPositiveButton(
"Save as",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
int len = input
.length();
if (!(len == 0)) {
final_filename=input.getText().toString.trim();
);
} else {
Toast.makeText(
getApplicationContext(),
"Enter Name Properly",
Toast.LENGTH_LONG)
.show();
}
}
});
al.setNegativeButton(
"Cancel",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.cancel();
}
});
AlertDialog alert = al.create();
alert.show();
}
});
al1.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int which) {
dialog.cancel();
}
});
AlertDialog alert1 = al1.create();
alert1.show();
}
});
}
});
And used final_filename like below:
File folder = new File(Environment.getExternalStorageDirectory(), "DCULogData");
File mLogFile = new File(folder.getPath(), final_filename);
And add permission in your manifest.xml file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Categories

Resources