Android Open Source - cnBeta Article D B






From Project

Back to project page cnBeta.

License

The source code is released under:

Apache License

If you think the Android project cnBeta listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.guest.cnbeta.database;
//w  w w .  ja  va2  s  .  com
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.guest.cnbeta.module.Article;

public class ArticleDB extends BaseDB {

  public ArticleDB(Context context) {
    super(context);
  }

  public List<Article> getList() {

    List<Article> list = new ArrayList<Article>();

    Cursor cursor = db.rawQuery(
        "SELECT * FROM article ORDER BY fromid DESC LIMIT 300", null);
    while (cursor.moveToNext()) {
      Article article = new Article();
      article.setId(cursor.getInt(1));
      article.setTitle(cursor.getString(2));
      article.setInfo(cursor.getString(3));
      article.setAvatar(cursor.getString(4));

      list.add(article);
    }
    cursor.close();

    return list;
  }

  public Article getByFromid(int fromid) {
    Article article = null;
    String sql = "SELECT * FROM article WHERE fromid = '" + fromid + "'";
    Cursor cursor = db.rawQuery(sql, null);
    if (cursor.getCount() >= 1) {
      article = new Article();
    }
    cursor.close();
    return article;
  }

  public void save(Article article) {
    if (getByFromid(article.getId()) == null) {
      String sql = "INSERT INTO article (fromid, title, info, avatar) VALUES "
          + "('"
          + article.getId()
          + "', '"
          + toSafeString(article.getTitle())
          + "', '"
          + toSafeString(article.getInfo())
          + "', '"
          + toSafeString(article.getAvatar()) + "')";

      db.execSQL(sql);
    }
  }

}




Java Source Code List

.ArticleActivity.java
.ArticleListService.java
.ArticleService.java
.Article.java
.CommentActivity.java
.CommentService.java
.Comment.java
.LoadSourceInterface.java
.LoadSource.java
.MainActivity.java
.PostCommentActivity.java
.Util.java
com.guest.cnbeta.FirstActivity.java
com.guest.cnbeta.SettingsActivity.java
com.guest.cnbeta.database.ArticleDB.java
com.guest.cnbeta.database.BaseDBHelper.java
com.guest.cnbeta.database.BaseDB.java
com.guest.cnbeta.loadsource.BaseLoadSource.java
com.guest.cnbeta.module.Avatar.java
com.guest.cnbeta.service.AvatarListService.java
com.guest.cnbeta.service.BaseService.java
com.guest.cnbeta.util.BaseApplication.java
com.guest.cnbeta.util.DataEngine.java
com.guest.cnbeta.util.FlingGallery.java
com.guest.cnbeta.util.NetworkStatusReceiver.java
com.guest.cnbeta.util.PullToRefreshListView.java
com.guest.cnbeta.util.ScaleAnimationHelper.java
com.guest.cnbeta.util.T.java