I really want to access files on android system. I manage to read files and directories in android external storage. My questions:
- How can I access internal storage directories and files (specially for videos, pics all apps that work in android).
- Where is the data of each application that is installed in the internal storage stored?
- Is it possible to transfer data that exists in internal storage (from internal storage to external storage?
- I read that external storage is world readable? what does it mean? (if you create an application, then this application can access all the files installed in external storage?)
2 answers
By default, an application cannot access data stored in another application. Permissions are applied to internal storage that make data written by an application inaccessible outside of that application (your application cannot read anything written by another application). This can be changed when an application can specify different permissions for OWN OWN data; basically, an application can let others read its data. However, unless an app specifically sets its permissions to allow it, other apps cannot access its data. This is a fundamental principle of Android's security/isolation model and is done at the Linux/kernel level as each app runs under its own Linux UID and permissions are set on the filesystem allowing that UID to access the app's directory structure (group and world permissions set to 0 default).
This all goes out of the box if you have root access on the device (the phone is built in and the app runs as root), but we have to consider that's out of scope for your question.
External storage (SD card) is different in that it is considered free for everyone and permissions do not apply there (this is natively due to the file system commonly used in SD not supporting permissions). Any application can normally read anything written to the SD card by any other application, unless the original application does something to protect it (encryption, etc.).
When trying to download a file to a Xiaomi phone, the user of the device may receive the message "Downloads require access to the device's memory." This dysfunction is usually caused by the settings of the Downloads and Browser applications, due to which the access of these applications to the phone's memory is blocked. We will deal with the specifics of this problem and options for solving it.
The essence of the problem of access requirements
As you know, the Android operating system allows the user to regulate the specifics of access of a particular mobile application to the system components of your phone. This is due both to the security policy (malicious applications cannot automatically access system components) and to the peculiarities of working with the battery, allowing you to use its potential more carefully.
![](https://i2.wp.com/rusadmin.biz/files/2018/06/3.png)
Getting the message "Downloads require access to device memory" usually means that your mobile browser settings have blocked access to the gadget's memory that it needs.
In some cases, a similar notice may also apply to the Downloads application, which is also denied said access.
Let's figure out how to solve the "Downloads require access" problem on Xiaomi.
What to do if in Xiaomi - Downloads require access to the device's memory
To fix the download problem on Xiaomi, there is no need to get root rights, flash the device or do other similar operations. The solutions to the problem are quite simple.
- First of all, check the overall performance of your mobile browser.
- Close it, then go to the device settings, and select "All applications" there.
- In the list of applications, find your browser, tap on it, and go to its settings, click on "Clear data", as well as on "Clear cache".
- Then close the gadget settings, launch the browser, and try to download the files you need again.
If the error continues to repeat, then you need to change the access settings of your browser and the Downloads application. Go to the settings of your Xiaomi, there select "All applications" - ("Third-party"), then "Browser", then "Application permissions", and activate the "Memory" slider there.
It is also recommended to carry out a similar action in relation to the application "Download" (or in English "Downloads"). In the device settings, you need to find the specified application, tap on it, and after entering its settings, move the "Memory" slider, which is responsible for the application's access to the latter. The problem will be solved.
Conclusion
In the vast majority of cases, the appearance of the message “Downloads require access to the device’s memory” means that the browser settings do not allow it to access the memory of your gadget. A simple and effective solution to the problem is to go to the device settings and give the browser (or the Downloads app) the necessary permissions, after which this problem will be effectively solved.
Last update: 03/21/2017
In the last topic, we covered saving and reading files from the application directory. By default, these files are available only to the application itself. However, we can place and work with files from external storage. This will also allow other programs to open these files and modify them as needed.
The whole mechanism of working with files will be the same as when working with the application storage. The key difference here will be getting and using the path to the external storage via the method Environment.getExternalStorageDirectory()
So, let's have the same interface markup in the activity_main.xml file:
And the MainActivity class code will look like this:
Package com.example.eugene.filesapp; import android.Manifest; import android.content.pm.PackageManager; import android.os.environment; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class MainActivity extends AppCompatActivity ( private final static String FILE_NAME = "content.txt"; private static final int REQUEST_PERMISSION_WRITE = 1001; private boolean permissionGranted; @Override protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R .layout.activity_main); ) private File getExternalPath() ( return(new File(Environment.getExternalStorageDirectory(), FILE_NAME)); ) // save file public void saveText(View view)( if(!permissionGranted)( checkPermissions() ; return; ) FileOutputStream fos = null; try ( EditText textBox = (EditText) findViewById(R.id.save_text); String text = textBox.getText().toString(); fos = new FileOutputStream(getExternalPath()); fos .write(text.getBytes()); Toast.makeText(this, "File saved", Toast.LENGTH_SHORT).show(); ) catch(IOException ex) ( Toast.makeText(this, ex.getMessage(), Toast .LENGTH_SHORT).show(); ) finally( try( if(fos!=null) fos.close (); ) catch(IOException ex)( Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT).show(); ) ) ) // open file public void openText(View view)( if(!permissionGranted)( checkPermissions (); return; ) FileInputStream fin = null; TextView textView = (TextView) findViewById(R.id.open_text); File file = getExternalPath(); // if file does not exist, exit if(!file.exists( )) return; try ( fin = new FileInputStream(file); byte bytes = new byte; fin.read(bytes); String text = new String (bytes); textView.setText(text); ) catch(IOException ex) ( Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT).show(); ) finally( try( if(fin!=null) fin.close(); ) catch(IOException ex)( Toast.makeText( this, ex.getMessage(), Toast.LENGTH_SHORT).show(); ) ) ) // check if external storage is read/write public boolean isExternalStorageWriteable()( String state = Environment.getExternalStorageState(); return Environment. MEDIA_MOUNTED.equals(state); ) // check if external storage is at least read-only public boolean isExternalStorageReadable()( String state = Environment.getExternalStorageState(); return (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) ; ) private boolean checkPermissions()( if(!isExternalStorageReadable() || !isExternalStorageWriteable())( Toast.makeText(this, "External storage not available", Toast.LENGTH_LONG).show(); return false; ) int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); if(permissionCheck!= PackageManager.PERMISSION_GRANTED)( ActivityCompat.requestPermissions(this, new String(Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_PERMISSION_WRITE); return false; ) return true; ) @Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions, @NonNull int grantResults)( switch (requestCode)( case REQUEST_PERMISSION_WRITE: if(grant Results.length > 0 && grantResults == PackageManager.PERMISSION_GRANTED)( permissionGranted = true; Toast.makeText(this, "Permissions granted", Toast.LENGTH_LONG).show(); ) else( Toast.makeText(this, "Permissions must be given", Toast.LENGTH_LONG).show(); ) break; ) ) )
Using the Environment.getExternalStorageDirectory() expression, we access the application folder in external storage and set the file object:
Private File getExternalPath() ( return(new File(Environment.getExternalStorageDirectory(), FILE_NAME)); )
Since permissions are required to read/write to external storage, you must check for permissions before saving and writing a file. The checkPermissions() method is defined for this. When the permissions are set, the onRequestPermissionsResult() method fires, which sets the permissionGranted variable to true if the permissions are successfully set.
To use external storage, you also need to set permissions in the AndroidManifest.xml file:
Do you have a question why downloads on Xiaomi require access to the device's memory, and what to do in this case? To solve the problem yourself, we present a step-by-step guide with pictures.
The limitation of phone memory access for most applications has been noticed by many users of Xiaomi smartphones, as well as owners of Android devices. Indeed, before the first launch of any downloaded application from the Play Market, the system requests access to the device's memory, location, calls, and more. Previously, each application received permission to dispose of data automatically, and the user could only know about the requirements of programs from their description in the Play Market. Now the owner of the device can make restrictions on their own.
Important: Many apps ask for permission to track your location. This not only calls into question the conditions of confidentiality, but also negatively affects energy consumption. After all, the smartphone will be forced to constantly access GPS or increase the load on the network in order to calculate the coordinates.
The error itself occurs because the application has not been granted permission to access memory. Accordingly, without this, the “Downloads” program cannot work, which is what notifies the owners of Xiaomi smartphones. The error can also be caused by third-party browsers that have restrictions on certain items.
How to fix
The solution is very simple and does not require special knowledge. The culprits are the browsers used, as well as the application "Downloads", in some smartphones of this brand it is called "Downloads". You need to check the settings of both applications and set them correctly.
Browser check
Check if the browser is working. If it opens without any warnings, then you need to go with other steps:
- Enter device settings. In order not to look for the corresponding icon in the menu, you need to move the top curtain down and click on the gear icon.
- Go to "All Applications".
- In the list, find the browser from which you plan to download. For convenience, you can use the search by name, and click on it.
- After opening, you will need to enter the "Application Permissions" section.
- In them, in order to start loading, you need to allow access to memory. To do this, move the slider on the "Memory" column.
- Next, you need to press the "Back" button on the device case, return to the previous item and open the "Memory" line.
- In it, click on "Erase data" and "Clear cache".
- Again, go back a step and go to the “Traffic” item.
- In it, move the slider to the right in all points.
Note: "Background traffic" can be disabled (do not move the slider to the right). In this case, the application will not be able to connect to the Internet when it is not being used. Because of this, it will stop sending notifications.
However, there are programs that can spend up to 300 MB of traffic in 2 weeks during the idle period (games are especially guilty of this). And thereby significantly reduce the volumes provided by cellular operators. Therefore, you need to check the consumption and disable background Internet access for such programs (the consumption in the background is displayed opposite the “Background traffic” item).
Checking downloads
The algorithm of actions is identical. It is necessary to repeat all of the above, but for the "Downloads" application (or "Downloads" for earlier versions of smartphones). However, the use of background traffic must be allowed here. Since during downtime, megabytes are practically not used. The ban can contribute to causing an error, so it is not recommended to disable background traffic consumption in this situation.
The described actions will help to completely eliminate the appearance of errors. By doing everything exactly, you will prevent the error “Downloads require access to device memory” on Xiaomi of all models and you will be able to start downloading any files.
Somewhere deep in the chest of your Android phone lies a storage device. It's like a hard drive on a computer: the thing can't be deleted, but that's not the point. The point is that the storage is used for your apps, music, videos, pictures and lots of other information. Here are a few things you can do to manage this storage.
Android phones come with 8GB, 16GB, 32GB or more internal storage.
Removable storage in the form of a microSD card is available on some phones, although this option is becoming less popular. MicroSD card capacity varies from 8GB to 64GB or higher.
GB is gigabyte, or 1 billion bytes (characters) of storage. A typical 2-hour movie takes up about 4 GB of storage. Most of the stuff you keep on your phone doesn't take up that much space. In fact, media stored in the cloud has almost no storage space.
View storage statistics
To find out how much free space is available on your phone, follow these steps:
Select Storage.
On Samsung phones, you'll find the Storage item in the General tab of the Settings app.
A typical data storage screen contains information about the storage location on the phone's internal memory and, if available, on the MicroSD card.
Phone storage information.
If your phone has external storage, look for the SD card category at the bottom of the storage screen.
Tap a category on the storage screen to view information about how the storage is being used or to launch the corresponding application. For example, click Applications to view a list of running applications. If you click "Pictures", "Videos", you can view images and videos.
Videos, music, and photos (in that order) consume the most space on your phone.
Media that you download to your phone from the Google cloud, such as movies or videos, are tracked in the Apps category.
Do not cry that the Total Space value is much less than the phone's memory. For example, a 16 GB phone only shows 12.55 GB. The missing space is considered an overhead, as well as a few gigabytes taken by the government for tax purposes.
File Management
You probably didn't get an Android phone because you liked managing your files on your computer and wanted one more thing to hone your skills. However, you can practice the same type of file manipulation on your phone as you would on a computer. Does it need to be done? Of course not! But if you want to get infected with files, you can.
Some android phones have an app to manage files. It's called "My Files" or "File Manager" and it's a traditional type of file manager, which means that if you don't manage files on your computer, you will experience this kind of the same pain and frustration on your phone.
If you just want to view files downloaded from the internet, open the Downloads app found in the app drawer.
If your phone lacks a file management app, you can get one quickly. There are many file management apps available on the Google Play Store. Metago's ASTRO file manager/browser is a good option.
Disabling the microSD card
The MicroSD card provides removable storage on multiple Android phones. When the phone is turned off, you can insert or remove the microSD card as you wish. The MicroSD card can also be removed while the phone is turned on, but you must disable the card first. Do the following:
Open the Settings app.
Select "Storage".
On some Samsung phones, open the General tab to find the Storage item.
Select Unmount SD Card.
This item is located at the bottom of the screen. Otherwise, your phone lacks the ability to host a removable microSD card.
Ignore the warning and click OK.
When you see the Mount SD Card action, you can remove the MicroSD card.
It is important that you follow the steps below to safely remove the MicroSD card. If you don't do this and you just pull the card out, it could damage the card and lose information.
You can insert a microSD card at any time.
Formatting MicroSD Memory
Your Android phone is designed to instantly recognize a MicroSD card when you insert it. If it doesn't, you can try formatting the card to see if that fixes the problem.
All data on the MicroSD card is erased by the formatting process.
To format a MicroSD card, first insert it into your phone. Then do the following to determine if the format is in order:
Open the Settings app.
Select Storage.
Select the SD card format.
Click the Format SD Card button.
Click the Delete All button to confirm.
MicroSD card is unmounted, formatted and then re-mounted and ready to use.
After formatting the card, you can use it to store information, music, apps, photos, etc.