Search code examples
androiddatabaseforcecloselow-memory

Android application force closes when memory is low


I am developing an application and a problem occured during testing. The main activity shows database records. When system memory is low (I push the home button and start a lot of apps) the garbage collector deletes the database records, and if I go back to the app, nothing is displayed on the activity (no records), and the app force closes on any actions (back, home, touch, etc.)

Any ideas to solve the problem?


Solution

  • Problem solved. It came out when system memory was extremely low (I launched 10 other applications to test my application), and I solved it by using the singleton pattern on the database class.