Android Performance optimization

Source: Internet
Author: User

First, layout optimization:

Follow one rule: layout level Small amount ( relativelayout to replace linearlayout, reduce necessary nodes, reasonable use <merge> labeling )

  1. Analyzing layouts using lint

  2. Hierarchyviewer

  3. load a view with viewstub delay ( optimize controls that are not required to be displayed immediately on the UI )

  4. Use <merge> optimize layout layer number
  5. Share layouts with <include >
  6. Use the SDK's layoutopt tool to analyze layouts to reduce the complexity of layouts
  7. Performance optimizations for the ListView

    The item minimizes the level of control and layout used, and Relativelayout is an absolute weapon that can reduce the level of layout. Reuse the control as much as possible, which reduces the memory usage of the ListView and reduces the number of GC times when sliding. The background color of the ListView is set to the same color as the cachecolorhint, which improves rendering performance when sliding. The GetView in the ListView is the key to performance, which should be optimized as much as possible. In the GetView method, it is not possible to do complicated logical computation in the View;getview method, especially the database operation, otherwise it will seriously affect the performance of sliding.



Reference:

http://rayleeya.iteye.com/blog/1961005


Second,Java code optimization:
  1. Cache (picture cache, Database cache, object data cache, etc.)

  2. Data type selection, object design (inheritance, composition), design patterns, etc.

  3. Algorithmic Logic ( free space to change time if necessary )

  4. Exceptions are used for error handling, not control procedures

  5. Early or late action

  6. Network optimization

  7. Using the NIO mechanism

Reference:

http://developer.android.com/training/articles/perf-tips.html (Java)

http://rayleeya.iteye.com/blog/1961005 (Java)

http://www.trinea.cn/android/java-android-performance/ (Java)

http://blog.csdn.net/innost/article/details/9008691 ( Traceview )


Third, database optimization:
  1. Index ( When a field data update frequency is low, the query frequency is high, often has the scope query (<, =, >=, <=) or the order by, the group by IS recommended to use the index; Multiple columns are accessed frequently, and each column contains duplicate values to consider building a composite index )

  2. Bulk INSERT, update using atomic operations

  3. Fewer result sets and fewer fields are returned at query time.

  4. use less cursor.getcolumnindex ( You can use the static variable to remember the index of a column while building a table, and call the index instead of each query.) )

  5. Some can use file operations, as far as possible to use file operations, file operations faster than the database operation is about 10 times times faster,

  6. Optimized SQL statement strings, custom transactions, etc.


Android Performance optimization

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.