編輯:關於android開發
1、獲取文件的最後修改時間
@SuppressLint("SimpleDateFormat")
public String getFileDataTime(File file) {
Date date = new Date(file.lastModified());
SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 24小時制
String LgTime = sdformat.format(date);
return LgTime;
}
@SuppressLint("SimpleDateFormat")
public int compareDataTime(String date1, String date2) {
java.text.DateFormat df = new java.text.SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
java.util.Calendar c1 = java.util.Calendar.getInstance();
java.util.Calendar c2 = java.util.Calendar.getInstance();
try {
c1.setTime(df.parse(date1));
c2.setTime(df.parse(date2));
} catch (java.text.ParseException e) {
System.err.println("error");
}
int result = c1.compareTo(c2);
if (result == 0)
System.out.println("c1==c2");
else if (result < 0)
System.out.println("c1c2");
return result;
}
public String[] compareStringPre(String[] Source, String[] Object) {
String[] result;
if (Source.length >= Object.length) {
result = new String[Source.length];
} else {
result = new String[Object.length];
}
int n = 0;
for (int i = 0; i < Object.length; i++) {
boolean flag = false;
for (int j = 0; j < Source.length; j++) {
if (Object[i].equals(Source[j])) {
flag = true;
}
}
if (!flag) {
result[n] = Object[i];
n++;
}
}
return result;
}
private boolean saveCrash(String crash) {
String fileName = "cache.txt";
try {
File file = new File(mstrFilePath, fileName);
FileOutputStream fos = new FileOutputStream(file);
fos.write(crash.toString().getBytes());
fos.close();
} catch (Exception e) {
return false;
}
return true;
}
public String readCrashData() {
String strDataLine = "";
String filePath = mstrFilePath + "/cache.txt";
File file = new File(filePath);
if (file.exists() == false)
return strDataLine;
long fileSize = file.length();
// 文件大於1M, 認為是無效數據, 直接刪除
if (fileSize >= 1 * 1024 * 1024) {
file.delete();
return strDataLine;
}
if (file.canRead() == false)
return strDataLine;
try {
FileInputStream in = new FileInputStream(file);
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
strDataLine = reader.readLine();
reader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return strDataLine;
} catch (IOException e) {
e.printStackTrace();
return strDataLine;
}
return strDataLine;
}
Android 設計隨便說說之簡單實踐(合理組合),android隨便說說
Android 設計隨便說說之簡單實踐(合理組合),android隨便說說上一篇(Android 設計隨便說說之簡單實踐(模塊劃分))例舉了應用商店設計來說明怎麼做模塊劃
Android 配置文件(activity)元素
Android 配置文件(activity)元素 語法: . . . 被包含在: 可以包含: 描述: 聲明實現了應用程序可視化
Android學習----自適應國際化語言,android----
Android學習----自適應國際化語言,android---- 【前言】 自適應的知識與編程無關,關鍵在於配置文件的修改。自適應的內容包括:
Android API Guides---Bluetooth
Android API Guides---Bluetooth Bluetooth Android平台包括藍牙網絡協議棧,它允許設備以無線方式與其他藍牙設備進行數據交換