I'm using Block Store in a test application that I uploaded to the Play Store as Internal Testing. I enabled cloud backup when saving data.
When I create a backup in Google Drive from a Samsung Galaxy S10e I'm able to successfully recover the stored data in Block Store on backup restore from the same Samsung Galaxy S10e (after doing a factory reset).
I'm trying to recover the same backup from different devices (Android emulator and Poco X3 Pro) but Block Store data is not recovered. The app is installed but on Block Store data read, nothing is returned.
It's also not working when I create a backup from the emulator or from the Poco X3 Pro and try to recover the data from the Samsung Galaxy S10e.
So it's currently only working from the Samsung phone to the same Samsung phone.
I've read the docs and the only restriction they mention is this:
Target devices are supported based on their vendors. Pixel devices can use this feature from Android 9 (API 29) and all other devices must be running Android 12 (API 31) or above.
And both, emulator and Poco, are running Android 12.
Is there any restriction for the Block Store data restore on different devices or is there any error I'm making?
Here is the code I use for storing data:
val client = Blockstore.getClient(this);
val inputKey = binding.etPreferenceKey.text.toString()
val inputString = binding.etPreferenceValue.text.toString()
val bytes = inputString.encodeToByteArray()
val storeBytesDataBuilder = StoreBytesData.Builder()
.setBytes(bytes)
.setKey(inputKey)
.setShouldBackupToCloud(true)
client.storeBytes(storeBytesDataBuilder.build())
And this is the code I'm using for retrieving data:
// Retrieve all key/value pairs for debugging
val retrieveRequest = RetrieveBytesRequest.Builder()
.setRetrieveAll(true)
.build()
client.retrieveBytes(retrieveRequest)
.addOnSuccessListener { result: RetrieveBytesResponse ->
val blockstoreDataMap = result.blockstoreDataMap
val stringBuilder = StringBuilder()
// fill stringBuilder with data to be shown
showText(stringBuilder.toString())
}
.addOnFailureListener { e: Exception? ->
showText("Failed to retrieve bytes");
}