First,
layout optimization:
Follow one rule: layout level Small amount ( relativelayout to replace linearlayout, reduce necessary nodes, reasonable use <merge> labeling )
Analyzing layouts using lint
Hierarchyviewer
load a view with viewstub delay ( optimize controls that are not required to be displayed immediately on the UI )
- Use <merge> optimize layout layer number
- Share layouts with <include >
- Use the SDK's layoutopt tool to analyze layouts to reduce the complexity of layouts
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:
Cache (picture cache, Database cache, object data cache, etc.)
Data type selection, object design (inheritance, composition), design patterns, etc.
Algorithmic Logic ( free space to change time if necessary )
Exceptions are used for error handling, not control procedures
Early or late action
Network optimization
- 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:
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 )
Bulk INSERT, update using atomic operations
Fewer result sets and fewer fields are returned at query time.
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.) )
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,
Optimized SQL statement strings, custom transactions, etc.
Android Performance optimization