I am developing OCR application and it has large size of resources which are copy from Computer directory into app folder using gradle build file. But it is generating very large size apk when im generating apk. What is the workaround I have to do for testing purpose when I install apk manually on my device through file storage and later for google play store.
The way you formatted your question, the answers you will get will be opinion based.
IMO:
During Developement:
Transfer the recourses you need from your pc to the device's external storage. (I.E. in downloads folder or something similar. I am not talking about any SD here.). This will be a time saver as you won't need to transfer these files everytime you build and re-run your app.
During Production:
I would suggest to not include the resources in your apk at all to achieve a small app size. Have the recourses reside on some server and implement some logic where the user downloads only what he needs when/if he needs it.
Related
I have an android application already available on playstore. It is a file transfer app between PC to Android using localhost. I'm using following java function within it:
To create directory/file/show list of files and many other file functions(append, byte read/write etc):
file.mkdir
directory.listFiles();
file.createNewFile()
I had also put
requestLegacyExternalStorage="true"
And it is working fine on android 10 after giving sufficient read/write external storage permission.
But the problem is that these will not work on android 11 as requestLegacyExternalStorage will not work. I have used MANAGE_EXTERNAL_STORAGE and the app works perfect but the problem is that playstore is not allowing it. (Don't know why they rejected the update)
I have also used getExternalFilesDir and it works perfect but don't like data to be in android folder and remove if app is deleted.
I have also tried to use download location and it works but the problem is getExternalStorageDirectory is deprecated:
File file = new File(Environment.getExternalStorageDirectory()+"/"+Environment.DIRECTORY_DOWNLOADS,"FileChat");
So what I wanted to ask how can I manage/use file library for android 11 to read/write/create/delete files and directory. It should not be in android folder as this will be deleted after app is deleted. Can I used public directory like downloads? If I can, what is the alternative to getExternalStorageDirectory()?
I don't need to read user data. Just want to have a directory in which app can store files. The read function is working as file is picked by user using intent.
Thanks in advance.
Top-level directory write access of shared storage is not available in Android 11, however you can use the existing File APIs to access the media and download collection folders like /Pictures, /Downloads, /DICM etc. It won't be possible to create your app's own folder as top level directory but it is possible to create a dedicated sub-directory in the default collection folders.
To keep your app running as expected on Android 10, requestLegacyExternalStorage flag will also be required since access to shared storage on Android 10 was restricted via MediaStore APIs only.
If transfer is only for your apps own files then put them in
File file = new File(Environment.getExternalStoragePublicDirectory(DIRECTORY_DOCUMENTS),"FileChat");
Or use Storage Access Framework to let the user choose and or create a directory on external storage inclusive removable micro sd card.
I have a Java desktop application that downloads tens to hundreds of MB of image and music data as part of its normal operation. It maintains a disk cache of this data. If part or all of the cache is removed, the app will notice and re-download the missing data.
This is a 20-year-old app and historically it has placed the data in a hidden (~/.myapp) directory under user.home. I'm planning an update, and I'm wondering if there are canonical locations for storing application cache data for Windows, MacOS and Linux, and if so, if there are standard ways of accessing those paths from Java.
The only precedents I'm aware of are Gradle and IntelliJ, both desktop Java apps. Gradle does what my app does currently; it creates a ~/.gradle directory and dumps data there. IntelliJ apparently tries to use more canonical paths as of the 2020 edition; e.g., on Macs it saves cache data to ~/Library/Application Support/JetBrains/<product><version>.
Is there a library that will provide me with the canonical location my app cache on each OS? If not, does someone have a list somewhere so I can create the directories in the right places manually?
I have an apk file present in 2 standalone servers both of which have separate download links.
I would like to know if it is possible to detect from which link the apk was downloaded after the app was installed and opened.
The download is via browser and the one of the requirements is that the build has to remain the same.
If you are just installing your APK as a link directly on a file server, and the APKs are exactly the same, then no, there is no way to do this.
Here are some work-arounds:
Google Play provides a way for you to do this, but they are doing this through broadcasting an intent to the application after it has been successfully installed. You could release the APKs through Google Play privately through the beta / alpha channel, and take advantage of this feature perhaps. You'd not be able to use a private file server though.
You could create your own application that downloads and installs
the APKs and mimics Google Play's functionality which I described
above. This would probably be ridiculous for you to do, and I don't recommend it.
You could differentiate the APKs in some way. You could keep the content exactly the same, but configure some fields in the build logic through Gradle using the buildConfigField. You could also do split apks, use flavors, or a number of other different creative solutions if you wish.
So if for some reason the above suggestions don't meet your requirements, another solution that would be extremely hacky would be to use different APK file names. The browser would download the APK to the download folder, and you could probably look at the Android downloads folder after opening the app and look at the file name. This would not be reliable in any way though, as users could easily delete the file before actually opening your app, or there could be old downloads also. You'd have to look for base file names, and identify the most recent file based on creation date.
Background
I am developing an android application that will only be used on Nexus 7 tablets (my team is also providing and has access to the hardware).
Problem
The app needs to be flexible to allow content to be added (by non-tech savvy users) to the app and accessed without an internet connection.
Our Idea
Android devices have a file system. We want to design a file system layout such that the people adding content to the application can drag and drop into the correct folder.
e.g.
AppName
Images
Videos
If the user adds a video to the videos folder of the device under our app, it will show up in the app.
We understand that this could easily go wrong (accidentally delete a folder, etc.) but this is out best attempt to solve this without having to update the app ourselves whenever new content comes up (and remember, no internet connection!).
The Question
Is it possible to access the android file system contents and insert them into an app as described in the "Our Idea" section? If so, how?
Yes. This is possible if you don't bother about content security. You can copy the content to any of the file system path in sdcard and your app can look for the folder and read the files .
Example , you can create a folder in sdcard as
sdcard/appname/media/
and create a layout to access the files in the device, and when user selects the files provide option to copy it to your sdcard/appname path.
Check this link
http://developer.android.com/training/basics/data-storage/files.html
Note : the sdcard path can be accessed if you connect to any external system ( PC).
I'm developing a mobile application using j2me. In my mobile app I connect with another device through bluetooth and perform some operations.
In my mobile application the jar file size is 80KB
I deploy the application in "Nokia c2-00" mobile. When I execute the application the memory of the jar file increases every time. Each time I execute the application the jar file size increases by 5 to 10 KB.
For example I deploy the application in nokia phone (At that time the jar size is 80KB on the mobile) and after running and exiting the application I check the size (it will become 85 KB, after that it increases to 90KB, etc) the size is increased.
I cannot understand why my app size is increased. Please help me figure out why the jar file is increasing in size and how to stop it from doing that.
What kind of thing is your app doing? I have seen this phenomenon when deploying MIDlets to Nokia S40 handsets before, and I attributed it to the app writing data to RMS. So the display is showing space consumed by the JAR, and by the MIDlet itself.
Does this sound like what could be happening?
Move a copy of the inflated / expanded JAR file back to your development platform, extract it and compare it with the original JAR contents to see what is being changed.
Something in your app or some library that your app is using may be adding some file containing some state to the JAR. That's a bad thing to do. The format of a ZIP/JAR file doesn't allow component files to be rewritten in-place. Instead, the new version of the component file has to be appended ... resulting in the JAR file growing.
This is a weird case. The jar should not grow once it is installed... For the jar to grow, its contents must be unpacked and re-packed together with the additional files into a new jar file. This scenario is unlikely to happen.
Anyway, can you share your jar and jad file? I'm thinking of testing this myself.