Is there a good way to clear memory in android? Because if I do this the memory is still increasing while I switch between activities.
public class Resurces extends AppCompatActivity {
private TextView wikipedia1,wikipedia2,googlemaps,googlePhotos;
private void clearMemory(){
wikipedia1.setOnClickListener(null);
wikipedia2.setOnClickListener(null);
googlemaps.setOnClickListener(null);
googlePhotos.setOnClickListener(null);
wikipedia2 = null;
wikipedia1 = null;
googlePhotos = null;
googlemaps = null;
Runtime.getRuntime().gc();
}
@Override
protected void onDestroy() {
super.onDestroy();
try{
clearMemory();
Runtime.getRuntime().gc();
finish();
}catch (Exception e){
e.printStackTrace();
}
}
}