제발 도와주세요
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button121"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="144dp"
android:layout_marginTop="244dp"
android:onClick="export"
android:text="Button1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
package com.programmerworld.qqqqqqqqqqqqqqqqqqqqq;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.FileOutputStream;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void export(View view){
StringBuilder data = new StringBuilder();
data.append("Time,Distance");
for (int i = 0; i<5; i++) {
data.append("\n"+String.valueOf(i)+","+String.valueOf(i*i));
}
try {
FileOutputStream out = openFileOutput("data.csv", Context.MODE_PRIVATE);
out.write((data.toString()).getBytes());
out.close();
Context context = getApplicationContext();
File filelocation = new File(getFilesDir(), "data.csv");
Uri path = FileProvider.getUriForFile(context, "programmerworld.qqqqqqqqqqqqqqqqqqqqq.fileprovider", filelocation);
Intent fileIntent = new Intent(Intent.ACTION_SEND);
fileIntent.setType("text/csv");
fileIntent.putExtra(Intent.EXTRA_SUBJECT, "Data");
fileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
fileIntent.putExtra(Intent.EXTRA_STREAM, path);
startActivity(Intent.createChooser(fileIntent, "Send mail"));
}catch(Exception e) {
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.programmerworld.qqqqqqqqqqqqqqqqqqqqq">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Qqqqqqqqqqqqqqqqqqqqq">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.programmerworld.qqqqqqqqqqqqqqqqqqqqq"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.File_provider_paths"
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>
이렇게 되어 있는데 앱을 실행하면 실행이 안돼요 ㅠㅠㅠ
제발 도와주세요