Shared Datasets in Android

Supun Ishara Weerasekara
3 min readOct 7, 2020

The optimum way of sharing your data with others for utilisation of the system storage.

Overview of shared storage

Recently, Using shared storage helps to utilise the system storage that can be accessible even if the application has been uninstalled. There are a couple of ways to access and store data in the Android system’s shared storages.

What are the types of shared storages?

1. Media Content

The system has provided separate standard public locations for different data types such as audio, video, images, etc. By using MediaStore API, you can access the separate common areas.

2. Document and Other files

The system has provided a specific location for containing other files such as PDF, EPUB documents, etc. Your application can be accessed these files with the use of Storage access framework in the platform.

3. Datasets

Android system caches the large datasets which multiple application can be used. This has been introduced in Android 11, and also it can be used API Level 30 or higher. The application can be accessed these datasets with API such as BlobStoreManager

Why are shared datasets important?

Multiple applications in the android system are being used pleather of datasets for different purposes. Most of the time, the same dataset might use in different applications. When it needs each time, the application is trying to download the data from the server. With shared data blobs, it can be reduced data redundancy over the network and disk too.

When the application needs to access a large set of data sets from the shared locations, it can be surfed shared datasets called shared data blobs and determine whether a new copy of the data is downloaded. Android system has been facilitated with new API with BlobStoreManager.

Blob datasets are being used BlobHandle object with higher security hash key which has derived with cryptographically-secure. Each instance contains the security key and some important specific identical information.

How to access shared data blobs.

Android system maintains the shared data blobs and controls the accessibility of the applications. When your app needs to contribute to blob datasets. by using below-mentioned methods, it can be granted permission to access and contribute.

  1. allowPackageAccess()

To grant access to a specific set of application on device by adding the app package name.

2. allowSameSignatureAccess()

To allow only applications whose certificate are signed the same KEY.

3. allowPublicAccess().

To grant access to all the application on a device.

To access shared data blobs, it needs to download identical detail information from the server. Then it can be checked the availability of the data to utilize in the apps.

How to check Dataset Availability in Shared Storages.

If the dataset is already available in the device, apps can be accessed using blobStoreManager. The following code snippet can be demonstrated the way of implementation.

If the dataset is not available in the data stores, we need to contribute it to the system by downloading data from the server.

Conclusion

As per the conclusion, it can be recapitulated the shared data blobs can be used to optimise the usage of the data stores in android device among the different applications in a more secure manner. For further details about BlobHandle objects and BlobStoreManager APIs

--

--

Supun Ishara Weerasekara

Senior Software Engineer, Full Stack Mobile Developer, MSc in IT Specialized in Mobile Programming and Cybersecurity, BSc In IT