我试图每 5 分钟读取一次文件,但我真的不知道怎么做!
这是我的代码:
public class MainActivity extends Activity implements OnClickListener {
Button bVe, bCl, bCo, bAd;
File tarjeta = Environment.getExternalStorageDirectory();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bVe = (Button) findViewById(R.id.bVehiculos);
bCl = (Button) findViewById(R.id.bClientes);
bAd = (Button) findViewById(R.id.bAdmin);
bVe.setOnClickListener(this);
bCl.setOnClickListener(this);
bAd.setOnClickListener(this);
File file1 = new File(tarjeta.getAbsolutePath()+"/.Info/Prices", "values.txt");
try {
FileInputStream fIn1 = new FileInputStream(file1);
InputStreamReader archivo1 = new InputStreamReader(fIn1);
BufferedReader br1 = new BufferedReader(archivo1);
String linea1 = br1.readLine();
String texto1 = "";
while (linea1!=null)
{
texto1 = texto1 + linea1 + "\n";
linea1 = br1.readLine();
}
br1.close();
archivo1.close();
} catch (IOException e) {
Toast.makeText(this, "Cant read", Toast.LENGTH_SHORT).show();
}
我需要的是当我在这个活动中时,它每 5 分钟读取一次文件。
我将非常感谢任何帮助!