{sharedpreferences sp; @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main);// Get Sharedpreferences instance try {//Get the app's context object through the package name context Context=createpackagecontext ("Com.example.homework", context_ignore_security);//Create SHAREDPREFERENCESSP = Context.getsharedpreferences ("Test") with the context of another application, Context.mode _world_readable+context.mode_wor
Android data storage I/O
In Android development, local data storage is inevitable. Today we will talk about how to store data using IO streams.
Here we simulate a demo of the QQ login interface to actually operate the IO stream.
Function Description: click the button to save
Learn android from scratch (Data Storage (2) Internal Storage. 36 .)
CallopenFileOutput()With the name of the file and the operating mode. This returnsFileOutputStream. PassOpenFileOutput () creates a FileoutputStream object
Write to the filewrite(). Create a Write object and perform data read/Write operations.
Close the streamclose(). Close the link.The abov
In the previous section, we learned how to use file for Android data storage. However, such data is stored in applications. Therefore, the size of such stored files must be limited, sometimes we need to store larger files, such as movies, which uses our sdsard memory card. Android also provides sdcard related operation
(); // start to parse the array while (reader. hasNext () {// if the current array or object has elements, the true reader is returned. beginObject (); // starts parsing the object while (reader. hasNext () {String tagName = reader. nextName (); // print the parsed data if (tagName. equals ("name") {System. out. println ("-->" + reader. nextString ();} else if (tagName. equals ("age") {System. out. println ("-->" + reader. nextInt ();} reader. endObj
This paper illustrates the large data processing and simultaneous reading and writing methods of Android SQLite operation. Share to everyone for your reference, specific as follows:
1. Bulk Write
The use of things, the first cache data, and then batch write data, greatly improve the speed
288, direct inset into 7 se
Self-study Android notes -- Case Study of Returning data in the Activity (Equipment Selection), androidactivity1. Create a program:
The above layout Code uses the control ProgressBar (progress bar), which is used to display the baby's life value, attack value and sensitivity. ProgressBar is usually used to access the network to display the Loading dialog box and the Progress displayed when downloading fi
Android development, sometimes we need to save information, then today to introduce, save the file to memory, as well as some of the SD card operation, and methods for reference.First, save the data in memory:The way in which data is saved in Java development public static Boolean saveuserinfo (String username,string password) {File File = new file ("/
database, and the SQLite operation method SQLiteDatabase object is provided.
Android does not impose any restrictions on the concept of super-standard SQLite. We recommend that you use a unique ID to quickly find the auto-increment key field of the record. This is not necessary private data, but if you implement a content provider, you must include a unique ID t
Android data storage-SharedPreference
As a complete application, data storage operations are essential. Therefore, the Android system provides four Data Storage Methods: SharedPreference, File, SQLite, and Content Provider. In the Androi
In the previous article "how to configure 163 mailbox in Android", we can use the following example:
The business logic is as follows: In the example, a text box is used to simulate user information. When the program exits, it stores the text file information and forwards it to the mail sending page, let the user Save the information to the mailbox. The Code is as follows:Save the sent information to your mailboxPackage com. Terry;Import
; Default: Break ; }
Second, the file system to do data sharing
With the context.getsharedpreferences (String filename,int mode) method, you can open an XML file with the location of the file in/data/data/package_name/shared_ Prefs/filename.xml, if it does n
The Android system has five types of data storage, namely file storage, SP storage, database storage, ContentProvider content provider, networked storage. Of these, the first four are local storage. The types of storage include simple text, window state storage, audio video data, and various data for XML registration f
transaction identifier is checked. If the setTransactionSuccessful () flag is not called, the transaction is rolled back. Otherwise, the transaction is committed. Db. endTransaction ();}}}
MyOpenHelper. java
** SQLiteOpenHelper: * A helper class to manage database creation and version management. * therefore, SQLiteOpenHelper is used to operate the database itself. To operate data in the database, you must use the library object method. */Import
DBOpeningHelper (this. getContext ());Return true;}/*** External applications insert data to this application*/@ OverridePublic Uri insert (Uri uri, ContentValues values){SQLiteDatabase db = dbHelper. getWritableDatabase ();Switch (MATCHER. match (uri )){Case CODE_NOPARAM:// If the primary key value is an auto-increment id value, the returned value is the primary key value. Otherwise, the value is the row
On Netease, data is cool
>.
It is also illustrated as follows:
I didn't get much use of the api to draw this image, but I used some of the techniques I used to draw those images.
The main program is as follows:
Package com. xcl. chart;/*** Canvas exercise * Self-drawn circular Chart (Dount chart) * similar to the circular Chart in Netease's data cool * author: xiongchuanliang * date: 2014-4-12 */im
There are two ways to upload pictures of Android, one is to upload them in a file stream, and the images are converted into binary. The other is to turn the picture into Base64 way upload, this blog I only introduce file stream, about Base64 way will be introduced in the next blog!The first is Android; image upload we need a path to the image, the same as the call to the local album or take pictures can ret
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.