I know this question is a little stupid but I cannot find where the settings of my preferences screen are stored.
I am using shared preferences this file is located at /data/data/my.package.name/shared_prefs/common.xml. However when I change something the changes are stored. I even implemented custom controls which can store their information so far. But however I cannot figure out where the settings are stored. /data/data/my.package.name/ is only one xml file which does not contain any related information. I also checked the virtual directories for multi user devices with no luck.
Here is my xml:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/my.package.name"
android:persistent="true" >
<PreferenceCategory android:title="#string/settings_basics_group" >
<EditTextPreference
android:key="nickname"
android:persistent="true"
android:positiveButtonText="#string/setting_change_name"
android:title="#string/settings_username" />
<my.package.name.controls.EmailPreference
android:key="mail"
android:title="#string/settings_email"
custom:domains="#array/known_email_domains" />
<Preference
android:summary="Mars"
android:title="#string/settings_current_location" />
<my.package.name.controls.DatePreference
android:key="birthday"
android:title="#string/settings_birthday" />
</PreferenceCategory>
</PreferenceScreen>
I would be really happy if somebody could explain me where these settings are stored.
For older Android versions including Jelly Bean (API 16) and older the answer of Dalmas is correct. So feel free to upvote that answer.
Beginning with Jelly Bean MR1 (API 17) there are new rules about path due the multiuser support:
I figured out that the settings file is located in /data/user/##/my.package.name/shared_prefs/my.package.name_preferences.xml where ## is my numeric user id.
For solving that path you need the ApplicationContext there you need to reflect mLoadedAPK and there mDataDir. For now I'm happy with that I could get the path from the debugger. Sorry to everyone who wants a ready to use code snippet, you have to do that yourself.
The app preferences are stored in the default shared preferences that you can retrieve with PreferenceManager.getDefaultSharedPreferences().
The XML file itself is located at /data/data/YOUR_PACKAGE_NAME/shared_prefs/YOUR_PACKAGE_NAME_preferences.xml
Related
Using DataBinding, I trying to access icon from mipmap folder, after write a code it not compile model class and it show error in log - "token recognition error". Look at the below screenshot even it not allowed #mipmap. If anyone know the reason Please let me know
<ImageView
android:id="#+id/img_page1"
android:layout_width="#dimen/splash_slider_circle"
android:layout_height="#dimen/splash_slider_circle"
android:src="#{slider.img1 ? #mipmap/ic_circle_filled : #mipmap/ic_circle_outline}" />
The exact reason for the described behaviour is unknown to me. But if it's inconvenient to move all your icons from mipmap to drawable folders, it's possible to import your generated R class in the layout and refer mipmaps in conditions starting with R.mipmap and using app:imageResource attribute:
<data>
<import type="your.package.R" />
...
</data>
<ImageView
...
app:imageResource="#{someConditionVariable ? R.mipmap.ic_for_true_condition : R.mipmap.ic_for_false_condition}"
... />
I've just started Windows phone 8 development with previous experience of Android Development.
I was just searching if there is any strings.xml like file in windows phone 8 where we can keep strings and specially color codes. Yes i want to keep my own color codes in windows phone 8 project so that i may refer these colors in my Pages XML and in code.
Suggestions are highly appreciated.
Special color codes can be placed in your App.xaml file in the resources part.
Use like the following:
<Application.Resources>
<SolidColorBrush x:Key="ColorWhite"
Color="#FFFFFFFF" />
<ImageBrush x:Key="BackGroundBrush"
ImageSource="SplashScreenImage.jpg" />
<Style x:Key="MyPageStyle"
TargetType="phone:PhoneApplicationPage">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="Background_WindowsPhone.png"
Stretch="UniformToFill" />
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
In your page you might then use the following:
<phone:ApplicationPage Style="{StaticResource MyPageStyle">
<Grid Background="{StaticResource BackGroundBrush}">
<TextBlock Text="Hi"
Foreground="{StaticResource ColorWhite}" />
</Grid>
</phone:ApplicationPage>
I am trying to use PhoneNumberFormattingTextWatcher but there is nothing happening as if the code is not there
here is the code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
EditText PhoneEdit = (EditText) findViewById(R.id.editText1);
PhoneEdit.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}
when entering 002010555666 it still the same no - or + or (), just the same without any formatting
is there anything missing in the code
help
Have had the same issue, but after removing android:digits="1234567890+" it gone.
I added a comment to YTerle's answer, but I wanted to put the complete answer below:
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="#string/phone_number"
android:layout_marginBottom="5dp"
android:ems="10"
android:maxLength="14"
android:id="#+id/phone" />
Then in the code put the following:
phoneView.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
I was having issues even after adding android:inputType="phone" in the XML.
The solution was to set the Language in the phone:
Settings -> Search for Language -> pick English (United States)
The format (999) 999-9999 is mostly used in the US, therefore the phone language should be set to that only.
Final Solution: The issue is only associated with the android:inputType you selected in XML. It won't work with the "number". You need to choose "phone" or no inputType.
I have used this in an application and it worked just fine in the emulator (Android_4.2_Emulator_Smartphone_Nexus_S using Platform 4.4.2, API 19) but had no effect at all when run on my Samsung Tab 3 device running Platform 4.1.2, API 17. Maybe it's device dependent? The documentation indicates it was introduced in API 1 so I would think it should have all the kinks worked out by now but evidently not.
Hi I'm having a problem with my xml file for my android app. It's spitting out this error
error: invalid start tag Category . . . here is the source code.
<?xml version="1.0" encoding="UTF-8" ?>
<Category>
<destination id="1" main_cat="Hotel">
<timestamp></timestamp>
<business_name><![CDATA[ Sugarland Hotel ]]></business_name>
<alias><![CDATA[ Sugarland Hotel ]]></alias>
<address><![CDATA[ Araneta Avenue ]]></address>
<city><![CDATA[ Bacolod ]]></city>
<subcategory><![CDATA[ Hotel ]]></subcategory>
<cuisine><![CDATA[ Italian,Asian ]]></cuisine>
<budget> </budget>
<features> </features>
<working_days><![CDATA[ Everyday ]]></working_days>
<opening><![CDATA[ 24/7 ]]></opening>
<ending> </ending>
<contact><![CDATA[ (34)435-2690 , (34)435-2780 ]]></contact>
<fax><![CDATA[ (34)435-2645 ]]></fax>
<email><![CDATA[ rooms#sugarlandhotel.com ]]></email>
<website><![CDATA[ www.sugarlandhotel.com ]]></website>
<payment_type><![CDATA[ cash,credit card,master card, visa ]]></payment_type>
<lat><![CDATA[ 10.6524789N ]]></lat>
<long><![CDATA[ 122.9372838E ]]></long>
<desc><![CDATA[ Experience a modern hacienda retreat that nurtures the charm and romance of old world plantation living. Extensively renovated beginning 2010, Sugarland hotel unvails a celebrated balance of nostalgia and contemporary style, Capturing its original southern elegence, luxury, and decadence. Machuca tiles form cool geometric patterns in the hallways. Hacienda hardwoord floors contrast modern furnishings and amenities in the dramatic suits. The sugarland lifestyle offers guests the finest sensory indulgences: signature hacienda service, soothing organic toiletries, heirloom recipes, and unmatched privacy and tranquility. ]]></desc>
<image> </image>
</destination>
</Category>
also i tried testing CDATA would i rather use it or go with xml schema. Thanks for the help in advance
Remove the whitespace in front of <?xml version="1.0" encoding="UTF-8" ?>. Nothing can appear before it.
Both IntelliJ and my browser say your XML is fine. There must be something else wrong.
Let's go to the point..
I make an Android application which target is Google APIs (Platform 2.2).
I want to parse the XML File which comes from the REST API.
The XML file likes this:
<title>EARTH WIND & FIRE Live in Concert</title>
I store that output in my String variable, which I can use later and since the output is in XML, I use XML Parser class of course.
And as you can see, since the rule of XML format doesn't allow the naked character, in this case my '&' character, it will show:
<title>EARTH WIND & FIRE Live in Concert</title>
So I change that character with this method: xml.replaceAll("&", "<![CDATA[&]]>");
xml is String and I replace my & with <![CDATA[&]]> tag.
And I follow this: Android how to parse CDATA TAG?
It says that I must use dbf.setCoalescing(true);
Everything goes fine and in my TextView shows the words EARTH WIND & FIRE Live in Concert. The ampersand character (&) is shown in my emulator (Platform 2.2).
But, when I try it in the device (Platform 2.1), it will show only EARTH WIND.
And I make the new emulator Google APIs (Platform 2.1), it shows EARTH WIND too.
Does anyone here face the same problem with me??
Is there any compatibility issue with the XML Parser or the <![CDATA[]]> tag in Android??
Thanks in advance...
In String.xml in resouces folder
<string name="my_string"><![CDATA[Please put Your long text here ]]></string>
if you want to access this string for textview:
<TextView
android:id="#+id/my_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/my_string"
android:textColor="#android:color/white"
android:textSize="14sp"
android:textStyle="bold" />