Questions tagged [android-file]

Specifically the Android `File` class, but may also refer to the generic concept of files under the Android operating system

Specifically the Android File class, but may also refer to the generic concept of files under the Android operating system.

Use this tag if you have reason to believe your usage of files under Android causes the error your question is referring to.

1038 questions
14
votes
2 answers

Android File Provider Illegal Argument Exception

I am using file provider to save photo to a given destination. I get: java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data while trying to open activity to capture image from camera. My manifest.xml…
14
votes
2 answers

Convert a file (<100Mo) in Base64 on Android

I am trying to convert a file from the sdcard to Base64 but it seems the file is too big and i get an OutOfMemoryError. Here is my code : InputStream inputStream = null;//You can get an inputStream using any IO API inputStream = new…
Labe
  • 1,262
  • 2
  • 20
  • 30
14
votes
4 answers

Android - Copy files from assets to /data/data folder

I need to use some files in my app. They are kept in asset folder. I saw discussions on SO, where the files are being copied from asset folder, to /data/data/ on the internal storage, and then being used. I get the code, but what I do…
superuser
  • 625
  • 3
  • 7
  • 19
14
votes
4 answers

Why does FileOutputStream throw FileNotFoundException?

The Android Developer reference (this page) says: Throws FileNotFoundException But at the very start, it says: Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist. If…
1owk3y
  • 1,115
  • 1
  • 15
  • 30
12
votes
1 answer

Questions about using Android Backup Service with a SQLite database

My app stores all user data and preferences in a SQLite database, which I'd like to persist if the user gets a new phone, reinstalls, or does a factory reset. I've done some reading in Android's Data Backup Guide and their Android Backup Service,…
NSouth
  • 5,067
  • 7
  • 48
  • 83
12
votes
3 answers

Android select mp3 file

Sorry if this has already been answered, but I can't specify my question very well. I have an activity that needs a song file from your device, and I want it when I press a button to open a dialog to ask you how you want to open a file (like to…
Sartheris Stormhammer
  • 2,534
  • 8
  • 37
  • 81
12
votes
3 answers

Android, how to choose save file location?

is there any solution how to choose the saving files location? maybe with the original file browser, to choose the destination? thank you!
David
  • 2,331
  • 4
  • 29
  • 42
11
votes
2 answers

How do I let a user upload files to internal storage?

I am writing a small app that reads files that must be regularly written to storage on the device from a source external to the device, be it USB, Bluetooth, Airdroid, etc. From what I've read, nothing like that can write to internal storage. I…
ProfK
  • 49,207
  • 121
  • 399
  • 775
11
votes
0 answers

Open folder content with default file manager in android

I am working with pdf files in my android app. In a Alert Dialog pressing "Yes" should open the pdf file location in default file manager app. I tried with this but it always open a chooser. Even-though it(ES File Explorer) opens with "Choose Path"…
Karthikeyan Ve
  • 2,550
  • 4
  • 22
  • 40
11
votes
1 answer

How to Get Absolute Path in Android for File?

btnimport.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent fileintent = new Intent(Intent.ACTION_GET_CONTENT); fileintent.setType("*/*"); try { …
Vihang Patel
  • 128
  • 1
  • 1
  • 6
11
votes
3 answers

add image to twitter share intent android

I'm trying to add an image to my twitter share intent. I save an image locally in one class and then in another I get the image and try to attach to my intent. Here is my code private void shareTwitter(){ try { FileInputStream fis; …
Hugo Boss
  • 213
  • 1
  • 3
  • 8
10
votes
4 answers

How can I delete file on Android 11 (API 30) without system confirmation dialog?

I have an app which records videos to shared MOVIES folder. I can delete those files on Android 11 (API 30) with contentResolver.delete(uri, null, null) method in my recorded videos activity. But if I reinstall the app then it looses permissions to…
user25
  • 2,873
  • 2
  • 30
  • 66
10
votes
4 answers

Read/write file to internal private storage

I'm porting the application from Symbian/iPhone to Android, part of which is saving some data into file. I used the FileOutputStream to save the file into private folder /data/data/package_name/files: FileOutputStream fos = iContext.openFileOutput(…
STeN
  • 6,262
  • 22
  • 80
  • 125
10
votes
5 answers

Writing Text File to SD Card fails

I have a strange problem I've come across. My app can write a simple textfile to the SD Card and sometimes it works for some people but not for others and I have no idea why. For some people, it force closes if they put some characters like ... in…
Paul
  • 1,714
  • 7
  • 22
  • 45
10
votes
1 answer

Why do I need the WRITE_EXTERNAL_STORAGE permission with getExternalCacheDir() on Android Lollipop?

My app writes (and reads) cache files to the getExternalCacheDir() location. Before Android Lollipop (API 21) I've been using this permission with success:
murrayc
  • 2,103
  • 4
  • 17
  • 32
1 2
3
69 70