我需要找到一种方法如何清除我的应用程序存储在缓存中的数据.基本上我使用Fedor(在ListView中的图像的延迟加载)惰性列表实现,我想在我加载例如100个图像时自动清除缓存.任何想法怎么做?
编辑: 代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
list=(ListView)findViewById(R.id.list);
adapter=new LazyAdapter(this, mStrings);
list.setAdapter(adapter);
deleteCache(this);
adapter.notifyDataSetChanged();
}
public static void deleteCache(Context context) {
try {
File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception e) {}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new …Run Code Online (Sandbox Code Playgroud) 我想清除正在增加的应用程序的数据缓存程序,现在我正在清除Settings-> Applications-> Manage Application-> My Application-> Clear Cache.
但我想通过程序化做,请帮助我.
我正在制作一个简单的Android Wear应用来控制我的恒温器,我正在用Volley发送POST请求来控制它们.Android Wear模拟器中的一切都运行良好(请求有效),但是,当应用程序在我的Moto 360上加载时,凌空请求被调用,但总是超时.
为什么我的截击请求会在我的手表上失败但是在模拟器上工作?其他应用程序的请求在我的手表上成功(例如,内置天气应用程序可以在大约3秒内加载天气数据).而且,最奇怪的部分:我的应用程序在我的手表上工作(成功发出截击请求),并且,在我从Android Studio安装到我的手表大约一天之后,它突然停止加载数据,原因并非明显.
到目前为止我尝试过的:
manifest.xml.这是我的代码(来自我的主视图的适配器):
public void refreshThermostatsRecyclerView(RequestQueue queue) {
String url = "https://mobile.skyport.io:9090/login"; // login call to the thermostats server Skyport
Log.w("myApp", "Starting /login call to Skyport"); // this gets called on simulator and watch
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
Response.Listener<String>() {
@Override
public void onResponse(String response) {
// …Run Code Online (Sandbox Code Playgroud)