Analysis on the Number Attribution Inquiry of Android Mobile Guardian
- 2021-07-06 11:47:17
- OfStack
Using the millet number attribution database, there are two tables data1 and data2
First, query the data1 form and intercept the first 7 digits of the mobile phone number
select outkey from data1 where id= "Before 7 Bit mobile phone number "
Then query the data2 table,
select location from data2 where id= "It was found out above outkey "
You can use subqueries
select location from data2 where id=(select outkey from data1 where id= "Before 7 Bit mobile phone number " )
Create a database tool class
Create a new package xxx. db. dao
Create a new class NumberAddressUtils and a new static method queryNumber
Call the SQLiteDatabase. openDatabase () method to get the SQLiteDatabase object, parameters: database path (/data/data/package name/files/xxx. db), cursor factory (null), opening mode (SQLiteDatabse.OPEN_READONLY)
Copy the database address. db into the/data/data/package name/files/ directory
Call rawQuery () method of SQLiteDatabase object, get Cursor object, query data, parameter: sql statement, string [] condition array
For example: select location from data2 where id= (select outkey from data1 where id=? ), new String [] {phone. subString (0, 7)}
while loops the Cursor object and calls the moveToNext () method of the Cursor object conditionally
The getString () method of the Cursor object is called in the loop, passing in the field index
Close the close () method of the cursor Cursor object
Return the obtained address
Copy the database from the assets directory to the data directory
On the welcome page, make a copy
Call the getAssets (). open () method to get the InputStream object, parameter: xxx. db filename
Get File object, new comes out, parameter: getFilesDir () gets the/data/data/Package/files/directory, xxx. db
Get FileOutputStream object, new out, parameter: File object
Define buffer byte [] buffer, 1-1024
Define length len
while cyclic read, condition: read length is not-1
Calls the write () method of the FileOutputStream object in the loop, parameter: buffer, starting from 0, len length
Call the close () method of the InputStream object
Determines no copy as long as it exists and length is greater than 0, and calls exist () method and length () method of File object greater than 0
NumberQueryAddressUtil.java
package com.qingguow.mobilesafe.utils;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class NumberQueryAddressUtil {
private static final String path = "/data/data/com.qingguow.mobilesafe/files/address.db";
/**
* Inquiry number attribution
* @param phone
* @return
*/
public static String queryAddress(String phone){
SQLiteDatabase db=SQLiteDatabase.openDatabase(path, null,SQLiteDatabase.OPEN_READONLY);
Cursor cursor=db.rawQuery("select location from data2 where id=(select outkey from data1 where id=?)", new String[]{phone.substring(0,7)});
while(cursor.moveToNext()){
String address=cursor.getString(0);
return address;
}
cursor.close();
return "";
}
}
Copy database
private void copyAddressDatabase() {
try {
// Judge whether it exists or not
File file = new File(getFilesDir(), "address.db");
if (file.exists() && file.length() > 0) {
return;
}
InputStream is = getAssets().open("address.db");
FileOutputStream fos = new FileOutputStream(file);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
is.close();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Recommended reading:
Analysis of Android Mobile Phone Guardian sim Card Binding
In-depth analysis of md5 encryption when Android mobile phone guard saves password
Explanation of Android Mobile Guardian Setup Wizard Page
Analysis of Android Mobile Phone Guardian Turning off Automatic Update
Analysis on the Attributes of Android Mobile Guardian Custom Control
Analysis of Android mobile phone guard reading contact person
Analysis on Android mobile phone guards receiving short message instructions and executing corresponding operations
Analysis on the principle of mobile phone positioning of Android mobile phone guard
Analysis of Android Mobile Guardian's Mobile Phone Realizing SMS Command to Obtain Location
The above content is this site to introduce to you Android mobile phone guard number attribution query related content, I hope to help you!