Project has been obtained, today. apk file to get another non-debug phone, to find a problem.
Because of the paint. So the points of the drawing data are stored in a. txt text file. Use USB to upload to the specified directory, but obviously unscientific, because the user downloaded your. apk file, you tell him, but also to copy the text file to the specified directory. So, I'm going to solve the problem. is to package the text file in the apk file, install the. APK and let's create a program directory. Then copy the text files to this directory directory, the user executes the program, you can draw, no need to let him copy the coordinates of the point of drawing data. In the same vein, the fact that I have the data for the design profile and the standard track profile is also going to be there initially.
Here's a way to solve the problem.
First of all. You have to name the implementation of the necessary files, only can be a-z,0-9 36 characters (it is so remind me) composed of the file name, and then under your project to create a new directory raw, generally this directory is not, because the files in this directory is not compressed, Instead, copy it directly into the APK file, and finally add your file to the raw directory, so it's a good first step.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvamlzahvjywk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Create a directory like this. Join the file and you can.
Add the file, then how to copy these files to the specified folder? Here are a few things that are actually the knowledge points of the file operation. First, infer that the specified file folder and file exists and that it does not exist before it is created. Second. Refer to the file in raw; third. Copy the raw file to the created file, or raw to write the file to the output stream. Then write the input stream to the file created on the phone.
Here I simply wrote a function, the first two parameters of the function, one is written to the file on the Phone folder path, one is the newly created file name Word. The third parameter is the most important, that is, the file in raw is indexed by the ID in the R.java under the Gen folder, just as the button in our interface is referenced in the program and is indexed by ID. This third parameter is an int, which is the ID of this file. R.java in the int type, you can see. The code for this function is as follows:
private void CopyFile (string filedirpath,string filename,int id) {String filePath = Filedirpath + "/" + filename;//file path tr y {file Dir = new File (filedirpath);//folder path if (!dir.exists ()) {//If not present, create path name Dir.mkdirs ();} folder exists, copy the required documents from the Raw folder in the APK to the folder file File = new file (FilePath); if (!file.exists ()) {//file does not exist InputStream is = Getresou RCEs (). Openrawresource (ID);//RAW data resource FileOutputStream fs = new FileOutputStream (file), byte[] buffer = new byte[1024 ];int count = 0;//Loop writes out while ((count = is.read (buffer)) > 0) {fs.write (buffer, 0, count);} Fs.close ();//Close stream is.close ();}} catch (Exception e) {e.printstacktrace ();}}
We are able to transport this function in the first activity's OnCreate method. After you install the. apk file, the program is opened for the first time. The specified file is created, and the file is copied from raw.
CreateFile ("/sdcard/test/data", "TB60.txt", r.raw.tb60) createFile ("/sdcard/test/guikuo", "Design track", "r.raw.sjgk"); CreateFile ("/sdcard/test/guikuo", "standard track profile. txt", r.raw.bzgk);
The number of references above is self-modifying. Just after you install it, if you do not execute the program, you will not find these directories. Since this is the first execution, it is only created. Next executes, it concludes that the file already exists, regardless of whether the transaction has not been completed.
In fact, this is a very easy detailed information, it is the operation of the file, but sometimes it is really used to get, of course. But not a text file. Music files can also be placed in this area, we can try more.
APK when Setup copies files to the specified folder that comes with your phone