- Scoped Storage in Android 10 & Android 11
- What was the problem with earlier storage ?
- This is how it is solved now
- What all permissions app need to access the files from scoped storage?
- Access media files from shared storage | Android Developers
- To provide a more enriched user experience, many apps allow users to contribute and access media that’s available on an…
- Access documents and other files from shared storage
- On devices that run Android 4.4 (API level 19) and higher, your app can interact with a documents provider, including…
- What does it mean for you?
- Microsoft Mobile Engineering
- How much phone storage do you need?
- What is internal phone storage?
- MB, GB, and TB explained
- How much storage do tasks take up?
- How to check your storage
- Apple
- Android
- What if I don’t have enough internal storage?
- 1. Expand your memory using a microSD card
- 2. Use cloud storage
- 3. Manually free up space
- 4. Purchase a new phone
- Other resources
Scoped Storage in Android 10 & Android 11
A secure and advanced app storage system for Android.
A controversial storage access change, slated for Android 10, becomes mandatory for Android 11. This blog talks about scoped storage, How we can access it and what does it mean for our app?
Before Android 10, storage was divided into private storage and shared storage. Private storage’s(android/data/
) access and contribution was limited to owner app alone. Apart from private storage, rest of the storage was called shared storage which is where all the media and non-media files were being stored. Any app with storage permission would be able to access this part of storage.
What was the problem with earlier storage ?
Limited access: Most of the apps do not need the access of whole storage since their use case are limited to certain types of files or files they own. One such use case can be a grocery app or an e-commerce app which needs storage access only to ask user to upload their profile picture.
Security: With storage access, an app can access a document as vulnerable as your bank statement or personal files. How would you like that?
Data organisation: Data/Files related to an app was scattered at multiple places in Shared Storage. If you have to uninstall the app and you want to clear all the corresponding data, that would not come easy.
This is how it is solved now
With Android 10, Google started to restructure the storage and change the way app accesses the storage so that all the mentioned problems can be eliminated. This storage division is called scoped storage.
Idea behind scoped storage was to divide whole storage into multiple blocks. An app would be provided access to the storage blocks which has relevant data for the app. In addition, system will bind storage to owner apps so that it becomes easier for the system to locate relevant files, corresponding to an app. This would also help to remove app specific data once app is uninstalled unless user does not want to.
This is how storage is divided now:
This storage remains same as before. Its app’s own private directory (/app/data/
) where app has unlimited access to read and write.
This is further divided into Media and Download collection. Media collection stores Image, Audio and Video files. Download collection would take care of non-media files.
What all permissions app need to access the files from scoped storage?
Earlier there was one permission to read all the files and another to write. Now with scoped storage, access is allotted based upon storage type and the ownership of the content.
1. App will have unlimited access to their internal and external storage for both read & write operation.
2. App will have unrestricted access to contribute files ( Media & Non-Media) as long as the file is stored in organised collection.
3. Media collection contributed by other apps can be accessed using ‘READ_STORAGE_PERMISSION’ permission. ‘WRITE_STORAGE_PERMISSION’ permission will be deprecated from next version and if used, will work same as ‘READ_STORAGE_PERMISSION’.
4. Non Media files contributed by other apps can be accessed using Storage access framework API. No explicit permission is needed. This does not mean that App can get access to all the directories ( Root, android/Data , Download directory etc.). Once user grants access to it, it will be complete access. (Read, Modify, Delete).
This is how we can access non-media Files. Here i am trying to access PDF file.
If App wants to select a custom folder, intent ACTION_OPEN_DOCUMENT can be replaced with ACTION_OPEN_DOCUMENT_TREE. ACTION_OPEN_DOCUMENT_TREE is introduced in android 11. This access will be valid till user reboots device. If app wants to persist the access, while accessing URI using content resolver , content resolver has to call takePersistableUriPermission method.
If App wants to create a file such as an email app saving attachment, intent can be replaced with ACTION_CREATE_DOCUMENT.
Access media files from shared storage | Android Developers
To provide a more enriched user experience, many apps allow users to contribute and access media that’s available on an…
Access documents and other files from shared storage
On devices that run Android 4.4 (API level 19) and higher, your app can interact with a documents provider, including…
Note: Media location is considered sensitive data now and would not be available unless app has ACCESS_MEDIA_LOCATION permission. It’s not a run time permission and has to be included in manifest. However it would be good idea to check this if app highly depends upon metadata or is an enterprise application where admin can remove the permission. If you want exact bytes of stored media, ‘MediaStore.setRequireOriginal(photoUri)’ has to be called.
So now apps can get access to specific block of memory. But what if I am a back up app which needs to access everything?
In Android 10, users tried to access the directories using storage access framework. Storage access framework was not intended for this purpose. Also, User complained about confusing UX. For such apps, a special permission is introduced in android 11. To ask the permission, Apps have to submit a declaration form to Google play. Once user grants the permission to have a broad access then user will get an unfiltered view of MediaStore that include non-media file. However, your app will not have access to external app directories.
Unfiltered view of Mediastore…What if my app uses custom file picker which displays exact data directories?
There is nothing you can do about it. You might want to use system picker from now on.
Alright so till this point we understand the reason behind scoped storage and the permission/methods to access it. Now let’s talk about scoped storage API changes over android 10 & 11.
Scoped storage was introduced in Android 10 but there were some controversial decision which enforced google to make API changes in Android 11.
1. In Android 10 and 11, Scoped storage is default behaviour. However app can request legacy external storage in Android 10 which is not the case in 11. Additionally In Android 10, Apps which wanted broader access, tried to use Storage access framework to select the directories which was not the intended purpose of storage framework. In Android 11, special access permission is introduced. Once Google play white list the app, special permission can be asked to the user.
2. In Android 10, UI for scoped storage permission looked same as earlier android version. So it would be hard for user to know if they are giving access to scoped storage or whole storage. With Android 11, permission UI will be updated so that user can clearly differentiate between different permissions he is providing.
3. In Android 11, Media store has been updated. User can do bulk delete/edit of media files which was not the case in Android 10. Additionally, Copying and Editing of files is possible in 11 but recommended only for one-off edits and small sized files since copying files will clutter user’s disk storage.
4. Android 10 has lack of support for native libraries and file path. This is use-case for apps written in c, c++. This support has been added in Android 11, in-fact this is the only use case where developer is expected to write new code. Under the hood file path api is a proxy to media storage api. so if possible, call media store api directly.
What does it mean for you?
if your app has files stored in Shared storage or outside app directory, you need to move them to app directory if you plan to target android 10 and above. Starting with Android 10 you will lose access to it.
Scoped storage is here to solve long time privacy issue. Although there were lots of controversial decisions and negative feedback in Android 10, It is here to stay. Starting September 2020, apps must target android 10 or later so unless you are an app which does not use storage, it’s recommended to start using scoped storage.
Lastly, thank you for reading the article! Any questions and suggestions are most welcome. See you soon.
Microsoft Mobile Engineering
#Mobile development articles and news brought to you by #MobileDevs working at @Microsoft
Источник
How much phone storage do you need?
Last updated: 4th Nov 2021 — Estimated read time: 8 minutes
What is internal phone storage?
Your internal phone storage (sometimes referred to as ‘memory’) is the amount of space you have available directly on your phone’s drive to store your data. Examples of external storage include microSD cards, memory sticks/USBs, and plug-in hard drives.
How much storage you have initially varies depending on the type of phone and model you have. Before purchasing a phone, you can view the different storage capacities, which will also alter the price (with more storage being pricier), so you get the right amount for you. If you end up buying a phone with too little storage, you may find yourself needing to expand it or deleting some information to clear up much-needed room.
The majority of smartphones nowadays come with one of the following storage options:
- 8GB (though this is very rare now, and will usually only be found in very cheap or old phones)
- 16GB
- 32GB
- 64GB (one of the most common available, alongside 128GB)
- 128GB (probably the most common, and sometimes lowest option available on the newest releases)
- 256GB
- 512GB (the highest capacity sold on smartphones)
If you need more than 512GB of storage, you can easily add more, such as through cloud storage or an external drive. These options can boost your storage massively, though it’s rare to need anything beyond 2TB at the moment.
MB, GB, and TB explained
MB stands for ‘Megabyte’, and is smaller than GB ‘Gigabyte’. 1GB is composed of 1,000MB. A ‘Terabyte’ (TB) is even bigger, and is made up of 1,000GBs.
Naturally, as phones have become more technologically advanced, the data that is required to complete tasks has also risen. So even though storage has become cheaper and more readily available over time, people need a higher amount of space to begin with.
However, it’s not just tasks on your phone that determine how much MB or GB of storage you need; there are a number of other factors that can affect this amount as well, such as:
- The display resolution on your screen — the higher the pixel resolution, the clearer and more detailed your screen, and the more data that is needed to showcase this clarity
- The quantity of images on a webpage — more data is needed to download images while opening a webpage than if it was just text
- The quality of graphics on a game — once again, the higher the resolution, the more data that is required to load it vividly
- The size of files attached in emails — the bigger the file, the larger the email as a whole, and the more data is needed to download it, particularly offline using 4G
Despite this, for the most part you’ll determine your internal storage by how much you use your phone, and the types of activities you do on it. Take a look below to see how much storage each task will take up on your smartphone.
How much storage do tasks take up?
Activity
MB or GB*
16GB for 4,000 photos if the images were 4MB each (high quality)
1.5GB per hour of video recording (1080p)
3GB per hour of video recording (2K)
Depends on the quality, but between 3MB and 10MB per song on your phone
Depends on the overall size of the app, but approximately between 5MB and 2GB per app downloaded onto your phone
280MB for an hour episode (SD)
440MB for an hour episode (HD)
As you can see, little tasks do build up over the month, and if you’re a heavy user in particular, you might find a notification on your phone claiming your storage is full before you realise it. Your phone will then stop storing or saving any new data, which you may lose, and you’ll be unable to do things like take pictures or record videos.
How to check your storage
If you don’t know how much internal storage you purchased for your phone, or simply want to see how much you’ve used up so far, here’s how to check on both Apple and Android.
Apple
- Go to Settings
- Go to General
- Scroll down to find iPhone Storage
- Open iPhone Storage and you’ll see a breakdown of how much each topic is using up of your total internal storage
If you keep looking down on this page, you may see Recommendations for clearing up unnecessary space, as well as a breakdown of how much MB or GB each application on your device is using up.
Further, if you tap on one of these applications, you’ll be able to see how much storage is being used for each minor task if that’s relevant, such as photos or Gifs within ‘Messages’.
You can delete apps from in here too.
Android
As there are so many Android models — Xiaomi, Google, and Huawei, to name a few — the process for this may be slightly different due to minor variations in the systems of each brand.
Here’s how to find your internal storage on a Samsung phone:
- Go to Settings
- Scroll down to find Device maintenance or Device care
- Within one of the above, choose Storage
- This should open up a page which will show a breakdown of your storage, including how much you’ve used so far of your total internal memory, as well as how much each task (Documents, Images, Audio, Videos, and Applications) uses up
You can learn more about the storage required for each application from here, and potentially remove any that you don’t need if you’re getting tight on space. On some models, you may also get a Free Up Space tab appear, which will recommend old files and photos you may want to remove.
What if I don’t have enough internal storage?
If you’ve gone into your storage settings and found that you don’t have enough internal storage for what you need to do, you have a few options:
1. Expand your memory using a microSD card
A microSD card is a small card that can be inserted into your phone to allow for extra storage. This card is removable and therefore insertable into other compatible devices. This won’t be an option for you if your phone doesn’t have a memory card slot. iPhones don’t have a slot for an SD card, but most Android models do.
2. Use cloud storage
Cloud storage is a method of storing data digitally. Users save their files, like documents and photos, over an internet connection to a server, which is then accessible from any device in the world, thus making it a universal storage space. As long as you can access the internet, you can access a cloud service.
If you have an iOS device, like an iPhone or iPad, you can use iCloud to store all, or some, of your photos, videos, documents, and apps to be accessed across all of your Apple products. As iOS products don’t allow the insertion of an SD card, this is a popular option amongst Apple owners.
If you have an Android phone or tablet, you can download apps like Google Drive, Dropbox, and OneDrive, which work similarly to the iCloud. You can save and store any sort of file to access from a compatible device, as long as you’re connected to the internet. iPhone users can also use one of these instead of iCloud if they prefer.
Be wary of subscription payments and monthly billing costs on these services, as some of them are only free up to a certain amount, whilst others require payment upfront to access the cloud storage to begin with. You may be able to experiment with a free trial before making up your mind.
3. Manually free up space
You have the option on both iOS and Android to manually free up some space on your internal storage. Whilst your storage can give you an idea on what’s taking up the most space, you’ll probably have to delete things like big photo files, long videos, and large applications. Instead of parting completely with them, you could transfer these items onto a computer to store them on there, as most laptops have larger memories than smartphones.
It’s good practice to refresh your phone every now and again, partaking in a little ‘spring cleaning’ by going through and deleting what you don’t need anymore. Many of us may forget that we saved files temporarily, or took photos we no longer want or need, and these things stay in the background taking up storage.
Another way of manually freeing up some storage space, however small, is by deleting the cache or data connected to certain apps, like your browser. Deleting the cache will delete your temporary internet files. You can do this in Settings under a specific app — it will usually say something along the lines of ‘Clear history and website data’.
4. Purchase a new phone
If none of these options work for you, your only remaining choice is to purchase a new phone with a larger internal storage capacity. Though this can be quite expensive, there are a number of budget phones available to buy on the market.
Additionally, Asda mobile have a large range of affordable mobile phones available to browse and buy online or in stores.
Other resources
For more in-depth reviews on what you can get for certain amounts of storage or data, feel free to read some of our other blog articles:
Follow us on Twitter for more helpful guides, tips and tricks!
Источник