mercredi 28 janvier 2015

Getting list of subfolders name and files name in android source package

I'm developing an android application that store sql files to update the sqlite database. And that sql script will run when user push certain button. This is where i put my sql files


Where i put my sql files


So far i've been using this solution to run my script: First, mapping my update to resource as update.xml



<resources>

<string name="update_list">
v2_9_11
</string>

<string-array name="v2_9_11">
<item>1_AlterTable_wapactivity</item>
</string-array>

</resources>


And get the sql script inside the file with this method :



private void runScript(String version_name){
try{
String[] sql_list = mGap.getResources().getStringArray(getArrayIdentifier(mGap, version_name));
for (String sql : sql_list) {
InputStream in = getClass().getResourceAsStream("/com/ods/scm/script/update/"+version_name+"/"+sql+".sql");
Reader fr = new InputStreamReader(in, "utf-8");
BufferedReader br = new BufferedReader(fr);
String s="";
String baris;
while((baris=br.readLine())!=null){
s+=baris;
}
mDbHelper.executeStatement(s);
}
insertUpdate(version_name);
}
catch(Exception e){
System.out.println(e.getMessage());
}
}


I get the String update and String sql file name from update.xml. The problem is, i want to get update ( in this case v2_9_11 as subfolder name from folder update ) and sql file name ( in this case 1_AlterTable_wapactivity.sql ) without mapping it in update.xml. Anyone can help me?


Aucun commentaire:

Enregistrer un commentaire