我使用Android工作室开发我的Android应用程序。我在子文件夹red_voznje中的Assets文件夹中创建了我在android studio中使用的文件。 这是我的代码
fileLinija = "smbzag";
if(TimeDay == 7) fileLinija += "sub";
else if(TimeDay == 1) fileLinija += "ned";
GetFromTime(fileLinija);
fileLinija = "zagsmb";
if(TimeDay == 7) fileLinija += "sub";
else if(TimeDay == 1) fileLinija += "ned";
GetToTime(fileLinija);
这里是GetToTime函数和GetFromTime基本相同我只是在TimeMinFromSmb而不是TimeMinToSmb中保存了resault
public void GetToTime(String file){
AssetManager mngr;
String red = null;
int Timemin=0;
int Timeh=0;
try{
mngr = getAssets();
InputStream is = mngr.open(file);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
do
{
red=br.readLine();
Timeh = Character.getNumericValue(red.charAt(0));
if(Timeh == 9){
break;
}
Timeh *= 10;
Timeh += Character.getNumericValue(red.charAt(1));
Timemin = Character.getNumericValue(red.charAt(3));
Timemin *= 10;
Timemin += Character.getNumericValue(red.charAt(4));
LinijaBusaToSmb = Character.getNumericValue(red.charAt(6));
LinijaBusaToSmb *= 10;
LinijaBusaToSmb += Character.getNumericValue(red.charAt(7));
}while((TimeH>Timeh)||((TimeH == Timeh)&&(Timemin<TimeMin)));//popraviti
if(TimeMin <= Timemin) {
TimeMinSmjerToSmb = Timemin - TimeMin;
TimeHSmjerToSmb = Timeh - TimeH;
}else{
TimeMinSmjerToSmb = 60 - TimeMin + Timemin;
TimeHSmjerToSmb = Timeh - TimeH - 1;
}
}
catch (Exception e){}
}
smbzag和zagsmb都存在于Assets文件夹中,但smbzag未在资产管理器创建InputStream时停止。我该怎么做才能解决这个问题?
答案 0 :(得分:0)
答案 1 :(得分:0)
确保您创建了资源文件夹,并将所有文件放在 app
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
答案 2 :(得分:0)
我已删除所有资源,并使用Windows资源管理器将其添加到资源目录中,并添加了扩展名.txt