This video shows the quick steps to create an App which can be used to access the files within the file system of your Android phone. Once a particular file is selected in the explorer/ browser, the path of the chosen file is shown in the App’s text box or Toast command.
We hope you like this video. For any query, suggestions or appreciations We will be glad to hear from you at: programmerworld1990@gmail.com
Source Code:
package com.example.myfileaccessapp;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;public class MainActivity extends AppCompatActivity {
private TextView textView;@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
}public void BrowseButton(View view){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(“*/*”);
startActivityForResult(intent, 1);
}@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
textView.setText(data.getDataString());
Toast.makeText(this.getApplicationContext(), data.getDataString(),Toast.LENGTH_LONG).show();
super.onActivityResult(requestCode, resultCode, data);
}
}
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.example.myfileaccessapp”><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/AppTheme”>
<activity android:name=”.MainActivity”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” /><category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application></manifest>