A method to modify number matching digits in Android programming _android

Source: Internet
Author: User
Tags sqlite sqlite database

This article illustrates the method of modifying number matching digits in Android programming. Share to everyone for your reference, specific as follows:

The default number matching digits on the Android2.1 is 7 digits, that is to say from right to left, if two numbers have 7 digits are matched, then consider the same number, such as +86 1234567 and 01234567 are the same number; So to determine if two numbers match, simply use "= =" It's not going to work.

Android added a function phone_numbers_equal to the SQLite layer to determine the number matching, which is database-level and the corresponding SQL statement is phone_numbers_equal, Android registers the function with 2 parameters and 3 parameters in the SQLite database, and the 2 parameters are no more than number A and number B, and 3 are a bool variable to indicate whether to use a strict match, which is specifically for Thailand, It seems that Thailand's number rules are very special, and in our country, this variable is generally 0.

To get to the point, to modify the number of Android numbers matching digits, in fact, is very simple, modify the OldPhoneNumberUtils.cpp file in the minimum number of matches is the number you want, the number in the function Phone_number_compare_loose function to use, This function is actually the real function of number matching, file location: external\sqlite\android

static int min_match = 7; 
Change to the number you want

There is also a Java function implementation on the Framwork layer, compareloosely (a,b), framewoeks\base\telephony\java\android\telephony\ Phonenumberutils.java, the Min_match that is used also needs to be modified.

"Note": 2.1 Phone_number_compare_loose and compareloosely function of the implementation of a few code, is a bug it will affect the English state of the 6-bit length of the number matching

I hope this article will help you with the Android program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.