The Android docs say:
By default, Auto Backup includes files in most of the directories that
are assigned to your app by the system
Shared preferences files
Files saved to your app's internal storage
etc
However, my app currently stores a SharedPreference item that isn't being saved after uninstalling.
Before I uninstall my app, my shared preference sharedPref.getInt("locationCount", 0) is 2. But when I uninstall and reinstall, it's reset back to it's original value of 0.
AndroidManifest.xml
<application
android:name=".CustomApplication"
android:allowBackup="true"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
Any idea why it isn't saving?
Backups occur automatically when all of the following conditions are met:
The user has enabled backup on the device. In Android 9, this setting is in Settings > System > Backup.
At least 24 hours have elapsed since the last backup.
The device is idle.
The device is connected to a Wi-Fi network (if the device user hasn't opted in to mobile-data backups).
Related
I am using the Android AutoBackup feature in my app. These are my manifest settings.
<application
android:allowBackup="true"
android:fullBackupContent="#xml/backup_rules"
android:fullBackupOnly="true"
Is there a way to know when the last backup for my app was made?
The only thing I have found says this:
schedule
Backup documentation
Frequency Apps must issue a request when there is data that is ready to be backed up. Requests from multiple apps are batched and executed every few hours. Backups happen automatically roughly once a day.
Also, it looks like if you write your own agent you can register for backup or restore events.
events
also, one last thing, when you implement the events it looks like backup gives access to the date of the last backup. As far as I can see, a customs agent gets you the info you need with some coding
examples
I noticed that re-installing my application (building it again and again in debug mode) sometimes clears my SP and sometimes not.
I thought that adding android:allowBackup="true" in the application tab in the Manifest.xml file might restore it anytime I re-build the app.
<application
android:allowBackup="true"
.
.
.
>
Does building the app over and over actually uninstall it and then re-install it? And if it actually works like that, does it work the same for release mode?
What android:allowBackup="true" actually does? I thought it creates a permanent file on the phone pointing to the important data that needs to be backed-up.
When updating an app via Google Play, what is the actual process? Is the app uninstalled and then re-installed? Or does it just update the necessary code?How does it affect the memory?
What is the real reason of my Shared-Preferences actually getting deleted?
When it comes to things like shared preferences, they typically should be preserved between debugging sessions (assuming you are not manually deleting the app from the emulator/device).
Check Visual Studio's setting to ensure that it is trying to preserve data/cache directories:
Preserve data/cache between application deploys
Read the section on "Fast Deployment" for how Xamarin handles debug build updates:
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-process
During development "Auto Backup" (android:allowBackup="true") is pretty much irrelevant, see the conditions below in which is it back up to your Google Drive account.
Backups occur automatically when all of the following conditions are met:
The user has enabled backup on the device.
At least 24 hours have elapsed since the last backup.
The device is idle.
The device is connected to a Wi-Fi network (if the device user hasn't opted in to mobile-data backups).
The Android (Back up user data with Auto Backup) documentation cover this in more detail.
I'm using the default backup manager ,BackupAgentHelper for shared prefrences
can someone explain these errors:
1.W/PackageManager: checkUidPermission(): android.permission.BACKUP of 10129 is denied.
2.W/RestoreSession: No data available for this package; not restoring
what are the possible cases in which backup does not occur.
note:I have already added android:allowBackup="true" attribute.
note2: i know the backup process doesn't create instant backup. i have tried waiting for 1 day.
I saw many people facing problems in using the Key/value backup API provided by Google. In my case, due to following reasons my backup/restore functionality was not working.
when you request backup using BackupManager.dataChanged() it doesn't backup your data instantly. I waited for 1 day,but my phone wasn't connected to Internet for long.so my backup was scheduled but never occurred.
while restoring data do remember that even after restore is finished, your shared preferences are not refreshed i.e sharedPref.contains("mypref") will return false.I don't know if its a bug or not, but when the activity is killed and restarted again shared preferences are set.
for Testing purpose you can view this link to have instant backups and restores
This backup API does not require any special permission. just
<application
android:allowBackup="true"
android:backupAgent="CreateBackup"/> is enough.
Does the Android Manifest check for the available components to be used before an application starts running, or does the system check for the Android Manifest every time a new component is being instantiated? By components I mean activities, services, etc...
What is the process involved?
Also, can an application still go back and forth to check on the android manifest even after it is running to check on xml activity attributes such as the android:name, android:label, or even intent filters, for different purposes such as to see whether a component to be used has already been defined?
Well to say it in a simple way-
Manifest contains permission like- "SD card read/write permission". So, while installing an app if you don't have a SD card than your won't get installed.
Again manifest contains "minimum SDK version"- which checks what OS version you have in your mobile, if your mobile OS version is less than the minimum version defined in manifest than the app won't install in your mobile.
In the manifest you have a list of all the activities and services too. So, without adding these in the manifest- your activities/services wont work.
So, these sort of checking and permissions are in manifest - the information the system must have before it can run any of the app's code.
Hope i have been able to keep it short and simple :-D
The manifest is a part of the app - it gets packaged with the app in its installation APK.
The manifest tells the system what APIs the application will use. When the app is installed, the system tells the user what sets of potentially sensitive APIs the application will use (as listed int he manifest) and if the user allows the app to be installed the system then assumes that the use of those APIs is permitted.
The OS will not permit the app to use other sensitive APIs that the app did not declare in the manifest.
Android Manifest file contains important information like the Java package name of the application, permissions, descriptions about activities,services... The system must have these information before running the app code.By this reason, the system doesn´t check the Android Manifest in runtime.
More here:
Android Manifest - Android Developer
I have an android tablet that is locked down (users will only be able to use standard issue android browser), so all the temporary internet stuff should be in the same place.
Assuming I am able to root the device sometime here soon, I would like to be able to wipe out (1) cookies,(2) temp internet files,(3) history,(4) form data,(5) location access info,(6) passwords, (7) cache.
I think I can knock out most of these by erasing:
/data/data/com.android.browser/cache
The cookies appear to be in a database. I'm not sure if I can just delete it
/data/data/com.android.browser/databases/webview.db
And then I think I can just delete these files to erase location information:
/data/data/com.google.android.location/files/wifi
/data/data/com.google.android.location/files/cell
Will that take care of everything?
What am I leaving out?
Is it safe to just erase that database? Does anyone know?
how about something as simple as
adb shell pm clear com.android.browser
from command line ?
This API is deprecated in Android Marshmallow. If you build using API 23 it wont work any more.
You can delete them #micahhoover,
You can delete complete com.android.browser sub directories, every time you relaunch browser, all the sub folders gets created.
To delete android browser History(Default)
in your Activity.java file add the follwing code
Browser.clearHistory(getContentResolver());
In your manifest add
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>