Android: Implementing hidden Application features __android

Source: Internet
Author: User
Tags event listener sqlite sqlite database
Hide requirements for application functionality

Applications on Android devices are divided into system applications and user-installed applications. The system application can not be deleted, but some users do not use the system and can not be deleted, "the eye is not clear", you may use the hidden function to hide it. Some applications may not want to be used by others (people who want to play with your mobile phone), and they can be hidden using hidden features.

hide the knowledge involved in application functionality

1.GridView

The GridView is one of the data display controls in Android. The GridView view is arranged in a similar way to a matrix, and you can use Girdview when there are many elements on the screen (text, pictures, or other elements) that need to be displayed. Now that you have more than one element to display, you need to use Baseadapter to store these elements. The user may choose one of the elements to operate, which requires setting up an event listener Setonitemclicklistener to catch and handle events.

2. Data persistence

1 Use Preferences to store application data

Preferences is a lightweight data storage mechanism that includes data of some simple data types, including Boolean, int, float, long, and string types. stored in the form of a key-value pair in the application's private preferences directory (/data/data/< package name >/shared_prefs/), this preferences mechanism is widely used to store configuration information in the application.

2) file I/O

The Android platform mainly uses the two classes of Java.io.FileInputStream and Java.io.FileOutputStream to read and write files, and the Java.io.File class is used to construct an object that points specifically to a file or folder.

Note that each application's package will have a private directory of stored data, only the applications belonging to this package have write permissions, and the application's private data directory in each package is located on the Android system's absolute path/data/data/<package In the >/directory, the application also has write access to the/sdcard directory, the SD card on the Android device, in addition to the private directory. Other system directories in the file system, and third-party applications are not writable.

3) SQLite Database

In the actual application writing, in order to better the creation of SQLite data, open, change management, often write a Sqliteopenhelper database helper class to help us create and open the database.

Using the Sqlitedatabase object to manipulate the database, he specifically defines the relevant methods for operations such as Insert,upate,delete,select, in addition to the Execsql () and Rawquery () methods that directly parse the SQL statements.

The use of cursor: Querying the database will be wrapped in the results of the query in a cursor subclass object returned.

4) ContentProvider

When data needs to be shared between applications, we can use ContentProvider to define a URI for the database. After the other application queries or modifies the data, it is only necessary to obtain a contentresolver from the current context object and pass in the corresponding URI.

hidden application features detailed design

Hidden applications mainly involve four data types

Name

Type

Role

Mapps

List

Store package name for all installation applications on the device

Mdisapp

List

The package name of the application that holds the display

Hm

HashMap

The key value pair that holds the package name and flag

Db

SQLite database

Store user's about hidden settings


The user may install or uninstall the application during the operation, so consider the consistency of the data in HM and DB, ensure that the consistency of the two is done in the OnStop () and OnCreate () of the activity life cycle, the flowchart of the two is as follows:




Related Article

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.