I am making an app which use the following java line:
Net dnnNet = Dnn.readNetFromONNX("path\to\file");
As you can see, readNetFromONNX requires path to onnx file.
So I put my onnx file under assest folder, so I can use it at run time.
The problem is I you can only read assets foler with AssestManager and inputstream... the readNetFromONNX needs path...
How do I overcome this probelm? Is there a way to get the path of the file at run time? Maybe other folder?
Thanks from advance
Related
Is it possible to get the config.xml file that is generated by Cordova based applications using Adroguard?
I cannot find it under the /res folder and it is not listed in the output of get_files() method.
apktool, on the other hand, is able to get the config.xml from the apk that is use it on.
Since it is under res folder, You need to get it by unzipping the file to a temporary directory and then parse it using Axml parser. In get_files(), you must see "resources.arsc" file. The res files are part of that. You can do something like :
config_xml_path = os.path.join(<your apk unzipped path>, 'res', 'xml', 'config.xml')
with io.open(config_xml_path, 'rb') as axml_file:
parsed_axml_file = AXMLPrinter(axml_file.read())
axml_content = parsed_axml_file.get_buff().decode('utf-8)
parsed_axml = minidom.parseString(axml_content.encode('utf-8'))
You might get some errors if the config.xml is badly formatted but I am not including the solution to handle those case. I hope you will get an idea with the above example.
I need to extract the application icon in a APK file.
I'm using aapt to know the icon location inside the APK file.
I'm running aapt dump badging com.example.app.apk:
this command returns me:
(...)
application-icon-120:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-160:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-240:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-320:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-480:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-640:'res/drawable-anydpi-v26/ic_launcher.xml'
application-icon-65534:'res/drawable-anydpi-v26/ic_launcher.xml'
(...)
but as you can see it returns me the location of an XML file which in some way is encrypted. I know this XML file has the real path for the PNG file icon, but I don't know how can I get that real path (or how can I decrypt the XML and then parse it).
Is there any way to get the real path for an application icon inside a APK file with a XML pointing to other location?
Thanks!
Check out this project,
https://github.com/iBotPeaches/Apktool
It can be used to unarchive an APK, including the assets.
apktool d <your>.apk
try extract your apk file with 7-zip and you will get res foulder
I need to work with a file,that should be at data\data\app_name\files\ . That is now an SQL Database, so solution with SQLiteOpenHelper isn't ok for me. Also, I copyied that file to app_name\app\assets in my profect folder - that didn't work.
How to add that file to installation .apk, to put it in data\data\app_name\files during the installation?
Save your file in \res\raw within your project.
Then, you can access that file using:
InputStream databaseInputStream = getResources().openRawResource(R.raw.yourfile);
Make sure that the resource files are included correctly when generating the apk.
I'm trying to create a partition called "subdata" under "/data". But it's failing.
The steps I tried and the failure results are mentioned below.
File dir =new File(/data/subdata/");
boolean success = dir.mkdir();
Here, the "success" value is found "false".
File dir= context.getDir("/data/subdata",Context.MODE_WORLD_READABLE);
Here, I get "java.lang.IllegalArgumentException: File app_/data/subdata/ contains a path separator"
Please, help me in creating this subfolder under /data/ partition.
I solved my need in the below manner.
As I mentioned in the question that, if I create the sub folder manually, I'm able to read and write to that subfolder in the /data.
So, I created this subfolder through init.rc (as I mentioned, I have the build code also). As I'm more fluent in Linux than in Android, I fixed it through init.rc. Now I'm able to read/write to that folder through my android code.
I got this in my folders :
But on my android device, i have a file not found error because it looks for andoid_assets instead...
Where can i set my folder path ?
fixed,
do not put underscores as prefix for folder name..
Need to access the asset files from your main root(projectname->www) only on android device need to set the path like file:///android_asset/www/yourfilepath
E.g., file:///android_asset/www/images/xyz.png