parent
22ec554109
commit
464296c9af
@ -0,0 +1,13 @@ |
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import android.arch.persistence.room.Database; |
||||
import android.arch.persistence.room.RoomDatabase; |
||||
|
||||
/** |
||||
* Created by cto3543 on 28/06/2017. |
||||
*/ |
||||
|
||||
@Database(entities = {TootEntity.class}, version = 2, exportSchema = false) |
||||
abstract public class AppDatabase extends RoomDatabase { |
||||
public abstract TootDao tootDao(); |
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import android.arch.persistence.room.ColumnInfo; |
||||
import android.arch.persistence.room.Entity; |
||||
import android.arch.persistence.room.PrimaryKey; |
||||
|
||||
/** |
||||
* Created by cto3543 on 28/06/2017. |
||||
*/ |
||||
|
||||
@Entity |
||||
public class MediaEntity { |
||||
@PrimaryKey |
||||
private int uid; |
||||
|
||||
@ColumnInfo(name = "url") |
||||
private String text; |
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import android.arch.persistence.room.Dao; |
||||
import android.arch.persistence.room.Delete; |
||||
import android.arch.persistence.room.Insert; |
||||
import android.arch.persistence.room.Query; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by cto3543 on 28/06/2017. |
||||
*/ |
||||
|
||||
@Dao |
||||
public interface TootDao { |
||||
@Query("SELECT * FROM TootEntity") |
||||
List<TootEntity> loadAll(); |
||||
|
||||
@Query("SELECT * FROM TootEntity WHERE uid IN (:uid)") |
||||
List<TootEntity> loadAllByUserId(int... uid); |
||||
|
||||
@Insert |
||||
long insert(TootEntity users); |
||||
|
||||
@Insert |
||||
void insertAll(TootEntity... users); |
||||
|
||||
@Delete |
||||
void delete(TootEntity user); |
||||
} |
@ -0,0 +1,35 @@ |
||||
package com.keylesspalace.tusky.db; |
||||
|
||||
import android.arch.persistence.room.ColumnInfo; |
||||
import android.arch.persistence.room.Entity; |
||||
import android.arch.persistence.room.PrimaryKey; |
||||
|
||||
/** |
||||
* Created by cto3543 on 28/06/2017. |
||||
*/ |
||||
|
||||
@Entity |
||||
public class TootEntity { |
||||
@PrimaryKey(autoGenerate = true) |
||||
private int uid; |
||||
|
||||
@ColumnInfo(name = "text") |
||||
private String text; |
||||
|
||||
// set get
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public void setText(String text) { |
||||
this.text = text; |
||||
} |
||||
|
||||
public int getUid() { |
||||
return uid; |
||||
} |
||||
|
||||
public void setUid(int uid) { |
||||
this.uid = uid; |
||||
} |
||||
} |
Loading…
Reference in new issue