Programmer takes you to learn Android development series-android file storage

Source: Internet
Author: User

This is a tutorial for programmers who take you through the Android Development series. This article is dedicated to object-oriented programmers who can quickly learn to develop Android technology.

Previous post:. NET programmers quickly learn how Android development-layout and click events are written

It mainly explains the layout and the writing of click events.

The previous article added:

Control Unit Description:

px pixels

Dip or DP device independent pixels

SP proportional pixels

The height width of the control is typically dip or DP. Font with SP.

Android Storage Data item:

Description: Realize QQ login effect.

Enter your account password, and tick remember account number, click Login, save account information. The next login can directly display the last saved QQ account.

Front interface writing: (Of course, this is not the standard answer, everyone just put the layout of the cloth can be)

Process:

    1. User click the login button

    2. Background gets the status of the checkbox. If you do not check the operation.

    3. If the checkbox is checked, then the value entered by the QQ account will be saved.

    4. Open the app again, and the query stores the QQ account number. If available, it is displayed in the text box, otherwise it is not displayed.

Background handlers:

Java traditional notation, stored in a file.

After you install the app, the folder for the package name is automatically generated in the/data/data/directory. We are saving the data in the form of files to this directory.

We enter in the interface: Account name 123456 password 123456 hint:

At this point we find the saved file.

Click on the toolbar of Android Device Monitor


By following the path, export the file to your computer to display:

You'll also need to show your account password when you re-enter the app:

Write the following code in the OnCreate method: (That is, when initializing)

There are sometimes errors in the file's storage path, and the path is required whenever a file is involved in reading or writing. So Google programmers encapsulate a lot of ways to get the path directly to the application package.

These two APIs correspond to folders in.

Convenient for us to use.

Second, stored in the SDcard:

The special point of the SD card is that the status of the SDcard is indeterminate. Sometimes it can be used, sometimes it may be unplugged by the user. So we need to determine the status of the SD card. At one point is the SD card read and write requires certain permissions. The others are the same as above.

Judging status and common APIs:

Third, stored in the shareprefence:

Shareprefence: Save the data to use Shareprefence. is actually an XML config file. Usually only the current app has permission to read and write.

Write Shareprefences:

Read Shareprefences:

The next article explains the XML and SQLite operations.

If you feel the article can also, please click Subscribe to follow me.

Write code also to read, love the whole stack, more love life

Do the full stack siege lion

Can add groups to Exchange Learning: QQ Group number: 538742639

Programmer takes you to learn Android development series-android file storage

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.