In the past year, I made a small program to query the mobile phone number and zip code location, which has been sold on mm and Tianyi space. In this CU essay, I will introduce the details of this project.
First, the final
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" cell phone no. belonging "border =" 0 "alt =" cell phone no. belonging "height =" 411 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12LW5-0.jpg "/>
Program code structure
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" cell phone no. Belonging 2 "border =" 0 "alt =" cell phone no. Belonging 2 "height =" 293 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12M514-1.jpg "/>
1. Development Preparation
1) The development process first looks for the mobile phone number database from the network. I found mdb (Microsoft access). The better the new
2) The android database is sqlite, so we must create a database on the computer, import it to the program, download sqlite3 for windows on sqlite.org, and create a database mobile. db:
The name of the city list nationwide. Using id as the unique identifier can reduce the database size, because the file size in the android program cannot exceed 1 MB.
Click (here) to fold or open
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" cell phone no. Belonging 4 "border =" 0 "alt =" cell phone no. Belonging 4 "height =" 200 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12L151-2.jpg "/>
-- Carrier list
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" cell phone no. Belonging 3 "border =" 0 "alt =" cell phone no. Belonging 3 "height =" 96 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12H536-3.jpg "/>
--- Zip code of all cities
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" mobile phone number area number attribution 5 "border =" 0 "alt =" mobile phone number area number attribution 5 "height =" 192 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12M626-4.jpg "/>
-- List of carriers and cities corresponding to all mobile phone numbers. This table contains 44400 public data records. If the isp and city IDs are used as two fields, the data size exceeds 1 MB, I merge the isp and city IDS into one field with the highest bit ispid (isp only has three), and the last three digits are city (357) IDS), which can save the size of kb, the entire database is 806KB.
2. Start Development
I chose 1.6 for creating a new project, which is the latest version two years ago.
650) this. width = 650; "style =" background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px "title =" cell phone no. Belonging 6 "border =" 0 "alt =" cell phone no. Belonging 6 "height =" 342 "src =" http://www.bkjia.com/uploads/allimg/131228/0K12H0X-5.jpg "/>
2.1 AndroidManifest. xml is the most important file in android, which is similar to applicationContext in ssh. xml defines activities, permissions, and other information. I basically didn't modify this file, because it is a single machine and does not need to call permissions such as network Bluetooth and file writing.
2.2. Create a raw directory under the res directory to put mobile. db
2.3. res/values/strings. xml is the medium text used in the stored program. It is recommended that you do not write Chinese characters in the code to implement multilingual versions.
2.4 create a menu. The following @ + id/help indicates the id of the menu item.
2.4 page layout, my program interface is relatively simple with linear vertical layout
Main. xml:
2.5 main program
1) First, set the listening events for each button. The R. id. xxx in the event corresponds to main. xml.
Menu display menu and set menu events
The rest is to query the database.
Note that android cannot use this file as a database because the library I use is stored in raw (I don't know why ), my solution is to write this file to the android database, where the file can be read is usually under files under the installation directory of the program .)
This article is from "one party has" blog, please be sure to keep this source http://yifangyou.blog.51cto.com/900206/1032046