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
I suggest you put the .sql file in assets
folder. By doing that, you are free to manipulate your file with File IO API.
Sorry all, i just now put it in bounty but i'm able to resolve it by myself by the short time after i put it in bounty. Anyway, my solution is to open the apk file that inside the android device (data/app/....apk) as a zip stream. Then list all the file that start with com/ods/scm/script/update
. Here my method to get all file that start with it :
public ArrayList openApk(String filePath){
ArrayList<String> list = new ArrayList<String>();
FileInputStream fis = null;
ZipInputStream zipIs = null;
ZipEntry zEntry = null;
try {
fis = new FileInputStream(filePath);
zipIs = new ZipInputStream(new BufferedInputStream(fis));
while((zEntry = zipIs.getNextEntry()) != null){
if(zEntry.getName().startsWith("com/ods/scm/script/update/"))
list.add(zEntry.getName());
}
zipIs.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}