Android download manager copy file from cache - android

How to copy a file downloaded by download manager in internal storage's cache folder. I am using fileInputStream, but it through's permison denied. Is there any option to copy file

it has been a while since the question was asked but anyway, I found the answer this morning:
You simply can't copy files from you Caches folder. What you can do is to create your file in another folder (Files folder for example, which you get by doing getFilesDir()) and delete it if necessary !
Hope it helps,
Bye

Set permission in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />

Related

ExternalStorage does not create files in release version

The problem is that when developing in the debug version, everything is in order, I can easily write files to memory. But I'm making a release version for Google Play, and the logs show that it simply cannot create a folder / file.
I dug up all the documentation, all the permissions are as written, but apparently I still missed something. Tell me, help
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
android:minSdkVersion="30"
tools:ignore="ScopedStorage" />
android:requestLegacyExternalStorage="true"

I get (OS Error: No such file or directory, errno = 2) in Flutter when file.delete(). At the same file.exist() return true

I am developing a Flutter app. I am trying to add a functionality to delete a file in device storage. When i initialize a file object with the path to the file, and run file.exist() i get true. But when i run file.delete() i get
(OS Error: No such file or directory, errno = 2)when file.delete(). At the same file.exist() return true!
I have these permissions in my manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.STORAGE_INTERNAL" />
and
<application
android:requestLegacyExternalStorage="true"
And i am using permission_handler to ask for permission first.
Any idea?

How to access the DCIM folder on Android 8.1

I'm trying to save a file in the folder DCIM on my mobile phone (Samsung SM-N960F, Android 8.1.0); I'm using
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
to create a folder in the folder DCIM, but it's not working.
I suspect you do not have the proper permission for reading and writing to external storage. Add this to your project's build.manifest,
<manifest>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
...
</manifest>

Figure out who is adding READ_PHONE_STATE to my manifest file?

I am compiling a project that does not explicitly request the READ_PHONE_STATE permission, but when I compile I am seeing the permission in my compiled Android Manifest file. I'm assuming some library that's being pulled in is adding it explicitly or forgot to set its minimum SDK version (which would add it).
The only thing I have to go on is that in the final manifest, the permissions I requested myself look like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
And the READ_PHONE_STATE looks like this:
<android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
Does the android prefix mean anything?
Is there any way to narrow down which library is adding this permission?
You can exactly see if a (or because of) library adds some extra Permission to your manifest. Check at file generated (see below) during build process and look for the unwanted permission within the file!
Go to your project folder and look for this path:
[ProjectFolder]/build/outputs/logs/manifest-merger---report.txt
open the file and search for the permission
In my case I found these lines at the
uses-permission#android.permission.READ_PHONE_STATE IMPLIED from
C:\..\...\AppFolder\src\..\AndroidManifest.xml:2:1-14:12 reason:
com.some.evil.library has a targetSdkVersion < 4
This generated file show the output of the merge process described here in Android Developers site.
I would look at:
Android Library Manifest vs. App Manifest
This isn't really a duplicate so I won't flag, however I think he covers the topic fairly well in his answer to that question.
After that and assuming you can't figure it out, I would do the following:
Locate your gradle cache
Crack open the artifacts of each of your dependences (rename to .zip and extract is the easiest way to do this)
check if they have manifests included and see whats in the,

Couldn't find Application Package Name in Android device

So I make an Android app with package name com.xxx.xxx. I know that any installed app will create a folder in Android/Data/com.xxx.xxx. But my case is I can't find my application package name in that directory after I install it. Am I missing something?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ceria.tuntun"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Installed app wont necessary create a folder in Android/Data. There only the cache files are stored of your app, and that too if you have programmed your app to do so. By default the apps are stored in Internal memory in /data/data which can be accessed only if u have a rooted phone and a file browser for root users.
Which device r u using? You cannot see the application package in most of the devices because those do not have access to the internal storage if the app is installed in phone memory. You can access only SDCard.
the app is installed into the phone memory and not the SD Card by default. only the SD card files can be seen in an unrooted phone.
To install to SD card add this code to the manifest file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >

Categories

Resources