很抱歉,如果有这样的问题,我只想知道,我正在尝试读取服务器上的文件 .txt,然后我转换为 int,当我尝试使用 froyo 模拟器时我成功了
这是我的代码
final Context context = this;
TextView textServer, textApp;
final String textSource = "http://xxx/dev/android/androidversi.txt";
.txt 文件位置声明
URL textUrl;
String StringBuffer;
String stringText = "";
try {
textUrl = new URL(textSource);
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream()));
while ((StringBuffer = bufferReader.readLine()) != null)
{
stringText += StringBuffer;
}
bufferReader.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
上面的代码从服务器读取 .txt 文件,这个代码是果冻豆中的错误,因为我在 FROYO 上尝试过运行正常
PackageManager manager = getPackageManager();
PackageInfo info;
try {
info = manager.getPackageInfo(getPackageName(), 0);
int version = info.versionCode;
if(Integer.parseInt(stringText)>version) // I'VE CONVERTED STRING FROM .txt TO INT SO THAT I CAN COMPARE IT WITH VERSION ON APP
{
// IF VERSION ON SERVER > VERSION APP THERE IS LINK TO DOWNLOAD HERE
}
} catch (NameNotFoundException e){
e.printStackTrace();
}
比较版本
请帮我 :'(