1. Create the Assets folder and the Res/raw folder separately: (Note that the raw file is new under Res, and then create a folder with the name Raw)2. Create two txt files and copy them to the asset and raw folders:3. The effect of the implementation:4. Implementation code:(1) Layout file:1 XML version= "1.0" encoding= "Utf-8"?>2 LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/
readTextFile(File file) throws IOException{BufferedReader reader = new BufferedReader(new FileReader(file));StringBuilder text = new StringBuilder();String line;while((line = reader.readLine()) != null){text.append(line);text.append("\n");}reader.close();return text.toString();}}
The running effect is as follows:
Fro
(new File ("Data_10k.xml"));
Element foo = doc.getrootelement ();
List Allchildren = Foo.getchildren ();
for (int i=0;i
4.dom4j
Myxmlreader.java
import java.io.*;
Import java.util.*;
Import org.dom4j.*;
Import org.dom4j.io.*;
public class Myxmlreader {public
static void Main (String arge[]) {
Long lasting = System.currenttimemillis ();
try {
file F = new
(Content.getbytes ()); Fos.flush (); fos.close ();} catch (Exception e) {e.printstacktrace ();}} @Overridepublic void OnDestroy () {Super.ondestroy (); Stopself ();}}The code is relatively simple, so I don't have much of a stare. The next idea: When the service is turned on, the thread keeps reading the input stream from the Logcat.Put the read information into the file, the service stopped when the thread stop, it is so simple.Of course, to read int
File to save the data, save the path to/data/data/1 Public voidSave () {2String data = "Data to save";3FileOutputStream out =NULL;4BufferedWriter writer =NULL;5 Try {6out = Openfileoutput ("Data"), context.mode_private);7writer =NewBufferedWriter (NewOutputStreamWriter (out));8 writer.write (data);9}Catch(IOException e) {Ten e.printstacktrace (); One}finally { A Try { - if(Writer! =NULL) { - writer.close (); the } -}Catch(IOException
); Uri uri = uri.fromfile (new File); Mopenfilewebchromeclient.mfilepathcallbacks. Onreceivevalue (New uri[] {Uri}); } else {mopenfilewebchromeclient.mfilepathcallbacks. Onreceivevalue (NULL); }} mopenfilewebchromeclient.mfilepathcallback = null; Mopenfilewebchromeclient.mfilepathcallbacks = null; } }In this way, the data returned is the data required by the H5 page, so that the H5
Elf is a Unix-like system and of course includes executable file formats on Android (also including. So and. O class files). Can be understood as an EXE or DLL file format on an Android system. Understanding the Elf file specification is a prerequisite for understanding proc
ObjectiveIn recent projects, XML has used some properties that might not normally be used too often, possibly involving androidmanifest.xml, layout layouts, or to specific controls!Androidmanifest.xml① Add a tag in the Androidmanifest.xml file,The xxx.xxx.xxx is a third-party library package name, and if there are multiple libraries, separate them with commas. This is done so that the minimum version limit can be ignored for androidmanifest.xml in the
not high, more copy point code is always good. Now it's so cold in winter, it's good for you to exercise your fingers.Today I wrote this summary found that I still wrote hundreds of lines of code today, Android side. If you do not calculate the format class wrapping, about 100 more lines. The progress of the day is actually good.Tomorrow Friday, oh, today ...We still have to go to work in Saturday, so unscrupulous enterprises.Think about it, if it we
}
* @Description: ${todo} (describe what the file does in a word) * @author a18ccms a18ccms_gmail_com * @date ${date} ${time} * @version V1.0
*/ Type (Types) Comment Label (note for Class):/*** @ClassName: ${type_name}* @Description: ${todo} (here is a word describing the role of this class)* @author A18ccms a18ccms_gmail_com* @date ${date}
Previous articlesArticleThis section describes three primary methods for storing data in Android applications: sharedpreferences, internal storage, and external SD card storage. What is the method used in your application? The following are some suggestions:
1. If you have data in the form of key-value pairs, use the sharedpreferences object. For example, if you want to store some attributes of a user, such as name, skin color, birthday, or last logi
For example, when you open a text file in the document viewer, a list of software that can be opened is displayed;How can I make my software appear in this list? You can set the androidmanifest. xml file:
The first
Note that you need to change mimetype to the type you need. The text file is of course text/plain.
There are other common examples:
Text/plain (pl
The sharedpreferences object allows you to save data of the "key-Value Pair" type, such as user ID, birthday, gender, and ID card number. However, sometimes you need to use a traditional file system to store data. For example, you may want to save an article, which will be displayed in your application. In the Android system, you can also use the java. Io package to implement this function.
In the
?A word of sharing: When deciding to learn an open source project, be sure to fully understand the project's finished product.Overview: Write more than 300 lines of code today. This project, and then the project failed.This project is a failed project and cannot be run.Well, really. Have failed.I was copying the project according to other people's projects.At first, I was very distressed every day, because life could not see the future.Personal techno
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.