Roboguice with different shared preferences names - android

I am using RoboGuice in my application, and i've grown a custom to creating multiple shared preferences files so that each file plays its own role, and contains only small number of keys
however, ever since i started using RoboGuice, it injects my sharedPreferences objects with a single default file.
Is it possible to somehow direct roboguice into creating multiple files ?

Haven't use RoboGuice forever, but back in a days this was the way:
https://code.google.com/p/roboguice/wiki/ProvidedInjections#Shared_Preferences

Related

Access Resources In Dynamic Feature Module of App Bundle

My usage scenario is a bit complicated.
In the dynamic form, I only have some views and resources. Those views should have access to those resources. In my base module, I will use these views from the activity of a basic module. Both my application and activity replace the attachBaseContext method.
But when I download and install the dynamic form, my views can not access resources using the task context. However, resources are accessible from applicationContext.
I do not understand how SplitCompat works. So the classes and resources loaded by the dynamic module connect only to applicationContext?
This problem is probably caused by an Android Studio bug. Clean the project and invalidate the cache, or build the project again.
You can take a look at how Dynamic Features are implemented in this sample.
There's sample code on how to open some resources, located in a dynamic module, from the base module.
Plus, the samples includes others dynamic modules with activities in implemented in Java/Kotlin and native.

What is the correct approach for developing react native apps

I am new in react-native. I am trying to develop my first app in react-native. I want to know what is the correct project structure for developing react-native apps.
As of now, I have created component in root folder. I want to know what approach should I take for defining model, utils, webservice urls in what structure.
Does it has some kinda framework as like express for creating project structure in nodejs.
From my experience in building quite a large app using react-native. I have followed this approach and it scales pretty well for a team of 5+ people working on it .
App folder : : In this folder I keep all the files/folders related to app. Do not add anything in root folder. the less convoluted the root folder is the better for new person to get started.
uicomponents :
The uicomponents folder holds all the generic controls that app needs. eg : Dropdowns, sliders, buttons, checkboxed. You can avoid this if you are using a external lib.
components :
This folder holds folders for each section of screen. I call it modules for app. Each module is specific area of app, namely : HomePage, UserData, Settings so on so forth. This varies from genre of the app. My happens to be enterprise app, So I have folders for each module for an app.
Utils :
I am big fan of keeping utils at one place. Things like text formatters, Db handers, Oauth Handlers and so on.
Stores, Dispatchers :
Anything related to flux, redux can go in there.
In general the app has to be broken down in appropriate folders and files. One specific part of the app or module as I say has to have its own folder. All the files needed by him has to be in it. This makes it easy to be maintained and reasoned about.
Avoid duplicating code from beginning. Keep reusable things in Utils. All control related components (inputs, buttons, checkboxes) at one place.
Always keep styles at one place. Use constant variables for colors, this makes making changes very easy. The constant file holds colors.

PreferenceScreen with "world writable"

I'm developing a library which can be used in multiple applications. The library contains a PreferenceScreen to set certain settings, which often only need to be set once.
I want to make sure the settings are shared (and able to be edited) across applications using my library and for that, I think I should set the SharedPreferences to world writable.
However PreferenceScreen seems to use the default shared preferences and although the packagename will be the same across, the mode is set to private.
How can I set the share mode for PreferenceScreen to world writable?

Usage of Shared Preferences in android library projects

Usage of Shared Preferences in android library projects is allowed?I am trying to work on rating bar but i am not sure whether i can use Shared preferences to write that.
If you have a Context, supplied to you by the app that is using your library, you can use SharedPreferences.
However, you need to be a bit careful to ensure that you do not accidentally try using the same keys as the app might use. You might consider using a unique SharedPreferences file, rather than getDefaultSharedPreferences().

Android Preferences - How Shareable is Shareable?

I'm using PreferenceActivity to let Android handle some persistent key/value pairs for my app.
According to the Android Preference docs :
Note that saved preferences are accessible only to the application that created them.
However, when further researching the security and permissions aspect of preferences, I come across questions like this one:
Android: Retrieving shared preferences of other application
where some users are saying that preferences may be made world readable and world writeable and that they are successfully able to access them across applications.
So my question is:
Are preferences inalienably inaccessible across applications or do I have to take precautions to make them so?
Note: I'm am not trying to use preferences to share data among apps. Quite the opposite - I want to know that any preferences my users set are secure from inspection/alteration by other apps.
From the above answers and comments, it looks to me like the android developer docs on this subject are a bit misleading.
I even found another place where the developer docs state explicitly that settings are not accessible across apps:
(Note that it is not possible to share settings data across application packages -- for that you will need a content provider.)
Reference to the above quote it here: http://developer.android.com/reference/android/app/Activity.html#SavingPersistentState
But the responses from #shruti and #raman-bhatia (thanks guys!) both support the fact that settings can be configured to be shareable across apps, as does the SO query I referenced in the question.
The clincher was finding this SO query: Difference between getDefaultSharedPreferences and getSharedPreferences which shows how it the default shared preferences file is initially configured as private.
Thanks to all. The answer is that the docs are misleading in that preferences can be coerced to being shareable across apps, but that PreferenceActivity will by default create a secure shared preferences file visible only to the components of the app from which originated.
There are modes associated with the shared preferences that you get to define when you create them.
For example, you can make them as "World Readable" or "World Writable" if you want the rest of the applications on your device to be aware of them.
You can thus use your own flags to adjust the transparency of the shared preferences that you create

Categories

Resources