Using an open source database in an Android project Litepal

Source: Internet
Author: User

Https://github.com/LitePalFramework/LitePal

Reference documents

http://blog.csdn.net/guolin_blog/article/details/38556989

Software: Android Studio

Referring to a bunch of data, the final discovery is basically a tune, as if no one encountered any problems. In fact, in the first use of the process, there will be some inexplicable errors. Finally, read the English on GitHub and find out that the wrong is so outrageous

The packages downloaded from the official website contain many of these jar packages.

Just think, the recent package copy into it, a hand residue, the Litepal-1.3.1.jar and Litepal-1.3.1-src.jar package are copied into Libs, so the problem came, follow the online process, out of a bunch of unknown errors. In fact, in a word, it is conflict.

Baidu found a lap, unexpectedly no one has encountered this problem, silently squat corner to see Chinese go

Crossing Network Interpretation

That is, a class file, a class file and a Java file synthesis.

The whole person is not good, will litepal-1.3.1.jar delete is OK.

Right Button-"Add as library"

Waiting .......

Observe Build.gradle

OK, almost halfway through.

Next, configure the Litepal.xml

Create a new Litepal.xml file in the project's assets directory

Configured as follows

Where dbname is the name of the database, version is the database and is used for database upgrade

List is a mapping function, <mapping class= "Com.test.model.Reader" ></mapping>

Com.test.model is the package name

Reader is the table name

Configuring the Androidmanifest.xml File

I understand that the role of header files in C should be the same as

At the beginning, import two jar package, will appear org.litepal.LitePalApplication red, error, delete one, and the Build.gradle file in the associated file deleted, OK, hand remnants ah, did not understand the principle, copy the results of the suit.

Finally, in the OnCreate file in activity, create a database to

Sqlitedatebase db = Connector.getdatabase ();

Create a table, build a class, name news

Complete

You can see if the creation was successful through the teiminal that comes with Android studio

View the database table structure

Using an open source database in an Android project Litepal

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.