@ -0,0 +1 @@
|
||||
AlarmAlertActivity.java
|
@ -0,0 +1,59 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.ui.bean.Note;
|
||||
import net.micode.notes.util.ToastUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class AddActivity extends Activity {
|
||||
|
||||
private EditText etContent;
|
||||
|
||||
private NoteDbOpenHelper mNoteDbOpenHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add);
|
||||
|
||||
etContent = findViewById(R.id.sf_et_1);
|
||||
|
||||
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
|
||||
|
||||
}
|
||||
|
||||
public void add(View view) {
|
||||
String content = etContent.getText().toString();
|
||||
|
||||
Note note = new Note();
|
||||
note.setContent(content);
|
||||
note.setCreatedTime(getCurrentTimeFormat());
|
||||
|
||||
long row = mNoteDbOpenHelper.insertData(note);
|
||||
if(row != -1){
|
||||
ToastUtil.toastShort(this,"Add Success");
|
||||
this.finish();
|
||||
}else{
|
||||
ToastUtil.toastShort(this,"Add Fail");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.ui.bean.Note;
|
||||
import net.micode.notes.util.ToastUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class EditActivity extends Activity {
|
||||
|
||||
private Note note;
|
||||
private EditText etContent;
|
||||
|
||||
private NoteDbOpenHelper mNoteDbOpenHelper;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_edit);
|
||||
|
||||
etContent = findViewById(R.id.sf_et_2);
|
||||
|
||||
initData();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
note = (Note) intent.getSerializableExtra("note");
|
||||
if(note!=null){
|
||||
etContent.setText(note.getContent());
|
||||
}
|
||||
|
||||
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
|
||||
|
||||
}
|
||||
|
||||
public void save(View view) {
|
||||
String content = etContent.getText().toString();
|
||||
|
||||
note.setContent(content);
|
||||
note.setCreatedTime(getCurrentTimeFormat());
|
||||
|
||||
long row = mNoteDbOpenHelper.updateData(note);
|
||||
|
||||
if(row != -1 && row != 0){
|
||||
ToastUtil.toastShort(this,"Edit Success");
|
||||
this.finish();
|
||||
}else{
|
||||
ToastUtil.toastShort(this,"Edit Fail");
|
||||
}
|
||||
}
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd HH:mm:ss");
|
||||
|
||||
TimeZone time = TimeZone.getTimeZone("Etc/GMT-8"); //转换为中国时区
|
||||
TimeZone.setDefault(time);
|
||||
Date date = new Date();
|
||||
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import net.micode.notes.ui.bean.Note;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NoteDbOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DB_NAME="noteSQLite.db";
|
||||
private static final String TABLE_NAME_NOTE = "note";
|
||||
private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_NOTE + " (id integer primary key autoincrement, content text, create_time text)";
|
||||
|
||||
|
||||
public NoteDbOpenHelper(Context context){
|
||||
super(context,DB_NAME,null,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
|
||||
db.execSQL(CREATE_TABLE_SQL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
public long insertData(Note note){
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("content",note.getContent());
|
||||
values.put("create_time",note.getCreatedTime());
|
||||
|
||||
return db.insert(TABLE_NAME_NOTE,null,values);
|
||||
|
||||
}
|
||||
|
||||
public int deleteFromDbById(String id){
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
return db.delete(TABLE_NAME_NOTE,"id like ?", new String[]{id});
|
||||
}
|
||||
|
||||
|
||||
public int updateData(Note note) {
|
||||
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
values.put("content", note.getContent());
|
||||
values.put("create_time", note.getCreatedTime());
|
||||
|
||||
return db.update(TABLE_NAME_NOTE, values, "id like ?", new String[]{note.getId()});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Note> queryAllFromDb(){
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
List<Note> notelist = new ArrayList<>();
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME_NOTE,null,null,null,null,null,null);
|
||||
if (cursor != null){
|
||||
|
||||
while (cursor.moveToNext()){
|
||||
String id = cursor.getString(cursor.getColumnIndex("id"));
|
||||
String content = cursor.getString(cursor.getColumnIndex("content"));
|
||||
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
|
||||
|
||||
Note note = new Note();
|
||||
note.setId(id);
|
||||
note.setContent(content);
|
||||
note.setCreatedTime(createTime);
|
||||
|
||||
notelist.add(note);
|
||||
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
}
|
||||
return notelist;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<Note> queryFromDbByContent(String content){
|
||||
if (TextUtils.isEmpty(content)){
|
||||
return queryAllFromDb();
|
||||
}
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
List<Note> noteList = new ArrayList<>();
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME_NOTE,null,"content like ?",new String[]{"%"+content+"%"},null,null,null);
|
||||
|
||||
if (cursor != null){
|
||||
while (cursor.moveToNext()){
|
||||
|
||||
String id = cursor.getString(cursor.getColumnIndex("id"));
|
||||
String content1 = cursor.getString(cursor.getColumnIndex("content"));
|
||||
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
|
||||
|
||||
Note note = new Note();
|
||||
note.setId(id);
|
||||
note.setContent(content1);
|
||||
note.setCreatedTime(createTime);
|
||||
noteList.add(note);
|
||||
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
}
|
||||
return noteList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.ui.adapter.MyAdapter;
|
||||
import net.micode.notes.ui.bean.Note;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class SafeFolderActivity extends Activity {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private Button mBtnNew;
|
||||
private List<Note> mNotes;
|
||||
private MyAdapter mMyAdapter;
|
||||
|
||||
private NoteDbOpenHelper mNoteDbOpenHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_safe_folder);
|
||||
|
||||
initView();
|
||||
initData();
|
||||
initEvent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
refreshDataFromDb();
|
||||
|
||||
}
|
||||
|
||||
private void refreshDataFromDb() {
|
||||
mNotes = getDataFromDB();
|
||||
mMyAdapter.refreshData(mNotes);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
mMyAdapter = new MyAdapter(this,mNotes);
|
||||
mRecyclerView.setAdapter(mMyAdapter);
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
mRecyclerView.setLayoutManager(linearLayoutManager);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
mNotes = new ArrayList<>();
|
||||
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
|
||||
|
||||
}
|
||||
|
||||
private List<Note> getDataFromDB() {
|
||||
return mNoteDbOpenHelper.queryAllFromDb();
|
||||
}
|
||||
|
||||
private String getCurrentTimeFormat(){
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
|
||||
private void initView(){
|
||||
|
||||
mRecyclerView = findViewById(R.id.sf_list);
|
||||
}
|
||||
|
||||
public void NewNotes(View view) {
|
||||
Intent intent = new Intent(SafeFolderActivity.this,AddActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//
|
||||
// getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
// SearchView searchView = (SearchView) menu.findItem(R.id.sf_menu_search).getActionView();
|
||||
//
|
||||
//
|
||||
// searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
// @Override
|
||||
// public boolean onQueryTextSubmit(String query) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onQueryTextChange(String newText) {
|
||||
// mNotes = mNoteDbOpenHelper.queryFromDbByContent(newText);
|
||||
// mMyAdapter.refreshData(mNotes);
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
// return super.onCreateOptionsMenu(menu);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.safe, menu);
|
||||
MenuItem x = menu.findItem(R.id.sf_menu_search);
|
||||
if (x.getActionView() != null) {
|
||||
Log.i("-------------","okk");
|
||||
}else{
|
||||
Log.i("-------------","false");
|
||||
}
|
||||
SearchView searchView = (SearchView) menu.findItem(R.id.sf_menu_search).getActionView();
|
||||
|
||||
|
||||
if (searchView != null) {
|
||||
Log.i("=====================","okk");
|
||||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String s) {
|
||||
mNotes = mNoteDbOpenHelper.queryFromDbByContent(s);
|
||||
mMyAdapter.refreshData(mNotes);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}else{
|
||||
Log.i("=====================","false");
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package net.micode.notes.ui.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.ui.EditActivity;
|
||||
import net.micode.notes.ui.NoteDbOpenHelper;
|
||||
import net.micode.notes.ui.NoteEditActivity;
|
||||
import net.micode.notes.ui.bean.Note;
|
||||
import net.micode.notes.util.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
|
||||
|
||||
private List<Note> mBeanList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
private NoteDbOpenHelper mNoteDbOpenHelper;
|
||||
|
||||
public MyAdapter(Context context,List<Note> mBeanList){
|
||||
this.mBeanList = mBeanList;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mNoteDbOpenHelper = new NoteDbOpenHelper(mContext);
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.list_item_layout,parent,false);
|
||||
|
||||
MyViewHolder myViewHolder= new MyViewHolder(view);
|
||||
return myViewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
|
||||
Note note = mBeanList.get(position);
|
||||
holder.mTvContent.setText(note.getContent());
|
||||
holder.mTvTime.setText(note.getCreatedTime());
|
||||
holder.rlContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Intent intent = new Intent(mContext, EditActivity.class);
|
||||
intent.putExtra("note",note);
|
||||
mContext.startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
holder.rlContainer.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
//长按
|
||||
Dialog dialog = new Dialog(mContext,android.R.style.Theme_DeviceDefault_Light_Dialog_NoActionBar_MinWidth);
|
||||
View view = mLayoutInflater.inflate(R.layout.list_item_dialog_layout, null);
|
||||
|
||||
TextView tvDelete = view.findViewById(R.id.tv_delete);
|
||||
|
||||
|
||||
tvDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int row = mNoteDbOpenHelper.deleteFromDbById(note.getId());
|
||||
if (row > 0){
|
||||
removeData(position);
|
||||
|
||||
ToastUtil.toastShort(mContext,"Delete Success");
|
||||
}else{
|
||||
ToastUtil.toastShort(mContext,"Delete Fail");
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setContentView(view);
|
||||
|
||||
dialog.show();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return mBeanList.size();
|
||||
}
|
||||
|
||||
public void refreshData(List<Note> notes){
|
||||
this.mBeanList = notes;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void removeData(int pos){
|
||||
mBeanList.remove(pos);
|
||||
notifyItemRemoved(pos);
|
||||
}
|
||||
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
TextView mTvContent;
|
||||
TextView mTvTime;
|
||||
ViewGroup rlContainer;
|
||||
|
||||
public MyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
this.mTvContent = itemView.findViewById(R.id.tv_content);
|
||||
this.mTvTime = itemView.findViewById(R.id.tv_time);
|
||||
this.rlContainer = itemView.findViewById(R.id.rl_item_container);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.micode.notes.ui.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Note implements Serializable {
|
||||
|
||||
private String content;
|
||||
private String createdTime;
|
||||
private String id;
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(String createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Note{" +
|
||||
"content='" + content + '\'' +
|
||||
", createdTime='" + createdTime + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.util.ToastUtil;
|
||||
|
||||
public class pwdActivity extends NotesListActivity {
|
||||
|
||||
public Button mBtnpwd;
|
||||
public EditText mEtpwd;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pwd);
|
||||
|
||||
mBtnpwd = findViewById(R.id.btn_pwd);
|
||||
mEtpwd = findViewById(R.id.et_1);
|
||||
|
||||
|
||||
mBtnpwd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String pwd = mEtpwd.getText().toString();
|
||||
Intent intent=null;
|
||||
|
||||
if(pwd.equals("123")){
|
||||
intent = new Intent(pwdActivity.this,SafeFolderActivity.class);
|
||||
startActivity(intent);
|
||||
}else{
|
||||
ToastUtil.toastShort(pwdActivity.this,"ERROR");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.micode.notes.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class SpfUtil {
|
||||
|
||||
private static String SPF_NAME = "noteSpf";
|
||||
|
||||
public static void saveString(Context context, String key, String value) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = spf.edit();
|
||||
edit.putString(key, value);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static String getString(Context context, String key) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getString(key, "");
|
||||
}
|
||||
|
||||
public static void saveInt(Context context, String key, int value) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = spf.edit();
|
||||
edit.putInt(key, value);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static int getInt(Context context, String key) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getInt(key, -1);
|
||||
}
|
||||
|
||||
public static int getIntWithDefault(Context context, String key, int defValue) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getInt(key, defValue);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package net.micode.notes.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ToastUtil {
|
||||
|
||||
public static void toastShort(Context context, String msg) {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void toastLong(Context context, String msg) {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue