Why is application data of the same application stored in different locations?


Question

I have installed the same application on




  • a device running Android 7.0 (not rooted) and


  • on a tablet running Android 4.4 (root),




but nevetheless I noticed that the application data (databases/files etc) is stored in different locations on each device:



On the tablet device the files are located at: /storage/sdcard0/Android/data/com.packagename and can be easily manipulated (i.e copy, back up etc) but not on the smartphone which likely leaves the storage location being: /data/data/com.packagename which I have no access to.






I understand that it is usually stored on /data/data (protected internal app storage) or /storage/sdcard0/Android/data (storage on user's internal storage partition), else on a SD card if present. In addition, a related question has been asked here: Where Android apps store data?



My biggest surprise is why is this happening on the same application (same version - sideloaded)?



This reference page also explains how a developer can configure the default location of application data. It would have been understandable if there were different versions of the application, but here I am only dealing with the same application (i.e .apk file). Is there something I am missing here or things have changed in recent versions of Android?



My concern is that I can't access these files on /data/data without root and since these are large files and I need to back them up just in case the app data is accidentally cleared (and I have already done that by mistake :(.



Most importantly I don't want to continuously download them over again.



Note: Both devices have no external storage attached.



From the look of things the biggest obstacle is not being able to access files on /data/data (device 1), hence no backup possible...(I would appreciate if there is another reliable workaround to achieve this)


Answer

As strange as it sounds, I had a successful workaround to this issue:




  • I had to manually move the necessary application data (files) from /data/data to /Android/data (with exception of shared_preferences folder and database folder i.e the normal config).


  • Second I had configure the app to use a private directory by modifying the userDefault.xml file (maybe different depending on application in question) and adding this necessary line of code:



    <int name="app_private_dir"value_"1"/>



Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes